DEV Community

Discussion on: "Haskell for the Front-End" :: Elm vs. PureScript

benjmhart profile image
Ben Hart

So, I can't speak to Elm as my experience is quite limited, however Elm's Language+Framework in One philosophy appears to bind it's domain quite strictly to front end development (Mainly SPA development)

However because of both it's language features and the development team's efforts to make great compiler messages, Elm has a reputation as being extremely beginner friendly and approachable.

Purescript, on the other hand, is more-or-less like writing haskell 2010, with a few type level adjustments which really make working in (and compiling to) the Browser or Node environment more bearable:

the biggest differences:
1) PureScript is strictly evaluated
2) PureScript uses Types that are encoded more similarly to those in Javascript. So where in Haskell we have String as a list and Text/ByteString, In PureScript we generally deal with JavaScript strings, Int and Float (Both of which are JavaScript Numbers), and we use Arrays as the default collection instead of linked lists.
3) PureScript has Anonymous Records and Row Types - essentially this allows for writing functions which depend on field names with a given type rather than requiring the function to operate on a specific type or typeclass.
4) PureScript typeclasses are more granular and better organized than Haskell since the creators are not tied to historical implementations

PureScript is not tied to a particular domain, you can write full-stack applications in PureScript.

I would say that other commenters recommending bower to get started with PureScript are using slightly outdated techniques, as it's much more common practive now to use the spago dependency manager & build tool.

there's a few operator differences and syntax querks, but largely you can write PureScript as if you were writing Haskell and get away with it.(Depending on how close to Haskell 2010 you normally write).

wolfadex profile image
Wolfgang Schuster

That's interesting about spago. I haven't looked at PureScript in months and was completely unaware. Definitely want to look at it more now!