3 ms·
F# has Query Expressions[1] which are just Computation Expressions[2], i.e. not a language extension, a library. If you know Haskell then it's pretty easy to g
by louthy 12y ago
F# has Query Expressions[1] which are just Computation Expressions[2], i.e. not a language extension, a library.
If you know Haskell then it's pretty easy to get into F#. The only thing you'll miss are higher-kinded types. Although they can be hacked in[3], it's not really worth the effort a lot of the time
[1] http://msdn.microsoft.com/en-GB/library/hh225374.aspx http://msdn.microsoft.com/en-GB/library/hh225374.aspx
[2] http://msdn.microsoft.com/en-us/library/dd233182.aspx http://msdn.microsoft.com/en-us/library/dd233182.aspx
[3] https://code.google.com/p/fsharp-typeclasses/ https://code.google.com/p/fsharp-typeclasses/
- platz 12y agoAgree - also I think f# can't dispatch on the return type of a polymorphic expression as I thought that was only possible with type classes?
- louthy 12y agoI think it's possible by including the return-type in the argument list and using inline operators. You really have to jump through hoops though to make it work and the resulting code is damn ugly. Take a look at the source for FsControl[1]. It implements what they call 'type methods'. So there's types for Monad.Bind, Functor.Map, Applicative.Pure, etc. I'm still trying to get my head around it; I thought I'd try to do so by implementing the core types and functions in Haskell's Pipes. So far I've managed to convince the F# compiler to take well over an hour to compile 70 lines of code! The main argument against them has been lack of CLR support. But it seems that there's already the FsControl way, so I think some syntactic sugar would go a long way. So yeah, until there's language support for type-classes I think it's probably not worth it. [1] https://github.com/gmpl/FsControl https://github.com/gmpl/FsControl