re: The Compile-To-JS Zoo VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Highly recommend Elm (it has everything, its own package system as well, no runtime exception - and that is true and has been tested in production).
 

It is somewhat Haskell like, but doesn't have typeclasses.

 

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

I hear both sides of the story. The general picture is:

  • people coming from JS are raving about Elm when they get it.
  • people coming from Haskell miss typeclasses a lot and are not fond of lack of typeclasses. I guess the only way to find out is try for yourself. It won't take a lot of time because you are familiar with Haskell.

I personally don't mind that at all. The language is very productive after all.

P.S. I was, maybe, a little bit misleading. It doesn't have typeclasses. But it has types and type inference as well. You can define your own types with custom types (previously known as union types).

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