4 ms·
Thank you for taking what seems to be an interesting approach to explaining these concepts. > I use OCaml in this tutorial, with some occurrences of Haskell.
by aargh_aargh 7y ago
Thank you for taking what seems to be an interesting approach to explaining these concepts.
> I use OCaml in this tutorial, with some occurrences of Haskell.
> My intention is for anyone familiar with the basics of typed functional programming to be able to follow along.
I don't know OCaml or Haskell and I got lost very early on due to the unfamiliar syntax. Do you think your explanation would be easy to translate to a more widely known language like Python or C?
- TheAsprngHacker 7y agoShrugs Well, Python is dynamically typed and C doesn't really have good polymorphism or first-class function support. Both polymorphism and first-class functions (with closures) are important for understanding functors, applicatives, and monads. I admit that I'm more fluent in OCaml than I am in Python or C, so please correct me if I'm mistaken.
- lmm 7y agoPython and C would indeed be unsuitable. Maybe Rust (quite OCaml-like, but with a more C-like syntax) or Java/C#/Kotlin would let you present these ideas with a more "mainstream" syntax?
- lonelappde 7y agoYou can do it in Scala which has powerful type support. The problem with other languages is that they lack the support for the higher order types, so the implementation is dishonest or you have to build up an API (new embedded minilanguage) to express them, which is a lot of work and a distraction. And, the result tends to be very cluttered with syntax junk, as you can see in Scala and Functional Java. Which incidentally is why people generally don't use these ideas in Java code. You can use these design ideas in your Java architecture, but not directly express them in your Java code.
- lmm 7y agoOCaml also lacks higher-kinded types. As far as I can tell, anything you can do in OCaml you can also do (perhaps verbosely, though less so in more recent versions) in Java.
- ernst_klim 7y agoOCaml have HKT, it's in the module part of the languiage, it's just verbose. And OCaml's module language is much more powerful than Java, since module language is a dependently typed language. You can't, say, pass a class including a type for another class in java.
- lalaithion 7y agoI wrote a very long and incomplete monad tutorial that primarily uses Python. It's very different from OP, but feel free to check it out. https://github.com/lalaithion/MonadPaper/tree/master/out https://github.com/lalaithion/MonadPaper/tree/master/out