My experience with Purescript so far
First off, the install and setup of the environment is straight forward. Pulp works like a charm! It is intuitive and it never went in my way. The incremental build is super fast on my machine so you can have a quick feedback on your test while you code with a simple
pulp --watch test.
The second thing purescript excels at is documentation browsing. If you look for the documentation of the
map function, just look up on pursuit. It’s a shame that the results are weidly ordered. I would have preferred to have the
Data.Functor (map) at the top, since it’s the most common. But this is only a detail, I’m sure maintainers are aware of these sort of things and are working towards a better browsing experience.
Another nice surprise is the Atom Ide. If you use Atom, it offers a nice ide that take care of autocomplete or source browsing. I need to restart the plugin from time to time to synchronise it with the current state of the build. Even with this minor problem, it’s impressive that such a young language has such a nice completion features. static types FTW!
Speaking of type system, Purescript is so pure that it won’t allow you to use partial functions without special treatments. This pushes you to a type driven development, which allowed me to learn a lot about the problems I was trying to solve.
Purescript does not come “batteries included”, you need to import every dependencies, even the
Purescript user experience
Let’s say you mistype the function
traversee. In Elixir, the compiler will warn you that there’s a more natural option: it will suggest methods in the context that look like your mistyping using the jaro distance. It’s a shame that the Purescript compiler does not do such things, even more because the type system would allow to suggest some very smart and elegant choices. No such explanation is given by purescript compiler.
module AddingNumbers where someAddition = 1 + 4
As I mentioned earlier, forgetting to import Prelude will award you with some weird messages like
Unknown operator (+). I feel like it’s a pain that could be avoided. Instead of such a message, the compiler could run through the functions it can access to, or maybe only through
Prelude to be faster, to suggest alternatives. In this case it could print:
Did you mean Prelude ((+)) ?.
Purescript leaves you alone in the jungle of its methods and functional jungle. If you don’t know what a
Foldable or a
<$> is, you better learn the language with tutorial first! It feels like the language wasn’t build for programmers first, but for Haskell programmers with strong theorical background. Could you easily tell the difference between a
Semigroupoid and a
The most representative to me is the
purescript-assert library, when the assertion work, everything is fine. But once you get an error, here’s the result:
As you can see, there’s no comprehensible error message, not even the line of the error in the
.purs test file. If you have more than one assertion in your tests, which is quite the norm, you can’t know which assertion fails. Fortunately, other libraries allow to perform testing with better output. I deeply regret that basic libraries don’t go in a spirit of helping the programmers. As this tweet says:
Programming languages should help programmers becoming better
Purescript only provides half the tools for the statement to be true.
Purescript could change
edit 13 December 2017: as mentioned here, Prelude is not included by design. It’s useful if you want to provide your own package. The paragraph mentioning it was edited accordingly.