re: The Compile-To-JS Zoo VIEW POST

re: If I can recommend the best presentation on the language, this one would be it.

This is my trepidation - typeclasses are one of the things I love most about Haskell. Is it limiting to not have an analogous system?

No, I do not find lack of typeclasses or HKTs limiting (in Elm or F#). F# has sorta-kinda-halfway emulations of typeclasses and HKTs using statically resolved type parameters (SRTP) and inline functions. F# itself uses those as convenient solutions to problems like equality and math operators. But I never use those in my own code. Immutable types already have built-in value equality in F#, and for other types of operations, I'd rather use it as MyTypeModule.opName for clarity of what it's doing and where the code lives. There are a few places where I would find HKTs useful, but it is not a big deal. I typically find I focus on types as data structures in F# and not so much on the type theory. And that makes coding pretty straightforward to read later albeit not quite as abstracted as it could be.

Great answer, thank you! It's true I mostly leverage Haskell's typeclasses in the form of libraries that provide powerful abstractions. My love for them came from studying them, but that love hasn't necessarily translated into real creative use much. Ease of reading is a huge point too. I have a lot of appreciation for what Clojure can do with only the most basic building blocks, and Elm seems to embrace a similar simplicity but with types.

Thanks for the links, too. Hadn't heard of SRTPs, that's pretty cool. I assumed the solution was always modules, OCaml style, like your example - not that that's a bad thing by a long shot.

code of conduct - report abuse