4 ms·
Not being familiar with core.typed: does it support parametric polymorphism? Can you dispatch based on types (e.g. typeclasses)?
by IsTom 13y ago
Not being familiar with core.typed: does it support parametric polymorphism? Can you dispatch based on types (e.g. typeclasses)?
- munificent 13y agoYes, Clojure has "protocols", which allow multiple dynamic dispatch on generic functions. http://clojure.org/protocols http://clojure.org/protocols
- chongli 13y agoRight, but protocols are not based on core.typed's annotations. There is no way to dispatch on the return type of a function, for example.
- brandonbloom 13y ago> There is no way to dispatch on the return type of a function, for example. A feature, in my opinion. See https://news.ycombinator.com/item?id=6459968 https://news.ycombinator.com/item?id=6459968
- chongli 13y agoA feature, in my opinion. Well, Clojure's a different language so it doesn't matter as much. If Clojure had enforced purity and pervasive laziness (a la Haskell) it'd be a real pain to use monads without polymorphic operators for them.
- brandonbloom 13y agoYou're assuming that Haskell's monadic approach is the ultimate approach to managing effects (which include delayed evaluation). Personally, I prefer the model in Eff [1] and proven as an alternative to monad transformers (although, still a single-layer monad in Haskell) [2]. Eff's approach utilizes capabilities [3], called "effect instances", to restrict access to effects. Much nicer, in my opinion. Hence, I've been experimenting with the ideas in Clojure [4]. [1]: http://math.andrej.com/eff/ http://math.andrej.com/eff/ [2]: http://lambda-the-ultimate.org/node/4786 http://lambda-the-ultimate.org/node/4786 [3]: http://erights.org/elib/capability/ode/ode-capabilities.html http://erights.org/elib/capability/ode/ode-capabilities.html [4]: https://github.com/brandonbloom/cleff https://github.com/brandonbloom/cleff
- chongli 13y agoI don't know enough about the theory to argue either way. I just really like Haskell's monad libraries (as well as applicative functors and lenses). If you're able to build a library that's as general, flexible and powerful in Clojure I will be really excited!
- adambard 13y agoI'm not at all sure about it, but I wonder if you could combine multimethods with core.typed's `cf` to accomplish this.