3 ms·
> since you need return type polymorphism to get `pure` to work). If you don't mind an extra layer of interpretation (which you might very well mind!) you can
by kenko 12y ago
> since you need return type polymorphism to get `pure` to work).
If you don't mind an extra layer of interpretation (which you might very well mind!) you can get around this by building up basically an AST of your applicative computation---I did this, more or less, in my monads-in-clj library: https://github.com/bwo/monads https://github.com/bwo/monads which has a kind of not-that-useful applicative definition: https://github.com/bwo/monads https://github.com/bwo/monads
I don't know too much about the innards of van Laarhoven lenses but I'd guess that a straight port might be inhibited by the fact that Clojure isn't pervasively lazy---so using Const as your functor, for instance, won't let you avoid actually computing the eventual second argument which is just discarded. But I dunno.
- tel 12y agoI was thinking about the applicative AST. I think that's a good solution, and perhaps if you're willing to explicitly compile it then you'll only need to pay once (and maybe even memoize it on later uses?) There shouldn't be a problem with strictness and van Laarhoven lenses. The particular trouble is just writing the lenses in the first place: (def one [inj] (fn [p] (fmap (fn [f] (pair f (snd p))) (inj (fst p))))) where did the `fmap` come from?