I’ve been reading Chris Okasaki’s Purely Functional Data Structures, and am wondering if there is a nice way to build lazy algorithms with F# inside of a monad that enables lazy computation (a Lazy monad). Chris used a custom extension for suspension / force syntax in SML, but I’d like to think that we could instead just use a simple monad in F#. Manual use of lazy and force in F# seems pretty cluttery.
I found this implementation in Scheme, but I don’t know how applicable it would be.
From my cursory knowledge and research, it seems both feasible and desirable within reasonable limitations.
Please let me know 🙂
To port Okasaki code, why not just go with F#
lazykeyword and some helper syntax to express forcing, for example:Since F# type system cannot properly express monads, I assume you suggest defining a computation expression for lazy computations. I guess one can do that, but how would that help exactly?