5 ms·
Haskell is easier to learn than it seems : https://patrickmn.com/software/the-haskell-pyramid/ https://patrickmn.com/software/the-haskell-pyramid/ Just get the
by weavie 8y ago
Haskell is easier to learn than it seems : https://patrickmn.com/software/the-haskell-pyramid/ https://patrickmn.com/software/the-haskell-pyramid/
Just get the basics down and write some stuff. For a lot of things, you don't need to know how they work underneath in order to use them. It is helpful to implement functors, applicatives and monads for some of the basic data structures to get a feel for things, but then beyond that, just use what has been provided. Don't try to write your own monad transformers, just use the mtl library. Lenses are really complicated to understand, but really simple to use. The servant web library uses some high end type level stuff in order to work, but it is really easy to use. The compiler has your back.
If something just doesn't work and doesn't make sense, just move on and find a different way. After a while you will understand more and can return to it.
Don't try to understand the academic papers that have been written with Haskell. There is a really tradition of making the Haskell code as incomprehensible as possible. It will just get you down.
- mark_l_watson 8y ago+1 for your Haskell comments That is what I do: I use a subset of the language, don’t dive too deeply into the theoretical stuff, for anything imperative I find an example to follow, and just enjoy writing pure code in a comfortable interactive environment (VSCode or Emacs). It is possible to just use Haskell ‘lightly’ and enjoy it. The only problem for me is that it can take me a while to understand other people’s Haskell code when I read it.
- weavie 8y agoYep. I agree reading other peoples Haskell can be a challenge. There is a real culture of making your code as terse as possible, which I think makes it easier to read once you know what you are doing, but makes it harder for beginners. Luckily Haskells type system means that you can understand a lot about what is going on just by looking at the type definitions. Most code includes these. Although rather frustratingly, however, a lot of documentation doesn't include the type definitions. It is good to see languages such as Idris make it mandatory to include type definitions for all functions.
- platz 8y agoI don't think servant is "really easy to use" for beginners. Even though you might not need to understand how it's implemented, you have to work with type-level code which is no intuitive for beginners.
- weavie 8y agoI guess it depends on your definition of "really easy". I'm not saying it's the easiest thing in the world, rather it is something that any developer can get if they are willing to bash their head against it for a time (and probably for not as long as they initially fear). I still don't completely understand what is going on in the route definitions, but I have no problem with setting up a route. Granted something like this is a gnarly type : type UserAPI2 = "users" :> "list-all" :> Get '[JSON] [User] :<|> "list-all" :> "users" :> Get '[JSON] [User] But really you don't need to think of it as a type, just think of it as setting up a couple of routes. The ':<|>' is the route separator. ':>' represents a '/'. The bit after the final ':>' is what your function needs to return. If you get it wrong the compiler will complain at you.
- platz 8y ago> If you get it wrong the compiler will complain at you. With an incomprehensible error message. Beginners will of course get it wrong. I would rather put beginners on a path that makes them feel like the compiler is helping them, one of the core strengths of Haskell, rather than it just telling them No.
- weavie 8y agoI get your point. I never found Servant a huge problem - it was the framework I started learning Haskell with and I found it was a really good fit. But - I can see others may not get it at first. It is quite different from other frameworks. Also, there are other areas where Servant gets complicated, getting and setting header values, cookies, returning redirects etc.. My original point was don't get bogged down in complicated stuff. If someone just doesn't get Servant, there is always Scotty, which is much more straightforward. Servant is not a reason to feel intimidated by Haskell.