Hacker News new | ask | show | jobs
by methodology 4334 days ago
How did learning how Algebraic Data Types are algebraic make you "get" Haskell?

When I learned Haskell, I just read Learn You A Hasekell in a few days, and immediately understood the practical value of Algebraic Data Types. They simply are like the types in C,Java,etc but more general because unions can have "fields". This alone means you can represent things like Maybe without any trouble, whereas in C/Java, you'd have to use casting, explicit tagged unions, or the visitor pattern. ML has largely the exact same features as Haskell, except you have to explicitly say which module you're using, instead of the typeclass system doing it for you. Do you also "get" ML? It sounds more like you are claiming to "get" some sort of theory, rather than Haskell or ML, which are trivial, but you make it sound like you need to be somehow enlightened to understand.

The only hard part I ever found in Haskell is lazy evaluation, which to me is just another type of magic which nobody gets, just like the Java Memory Model. The other hard part of Haskell are the extensions to type classes, which make you start thinking about open research problems.

edit: Which part of the above is downvoting material? Please explain so I can avoid being downvoted in the future.

1 comments

I think there's reason to believe that ADTs are both a major component of "getting" Haskell and a major topic in their own right of significant size beyond Haskell itself.

I've been plugging it a lot lately, but here's a post I wrote trying to emphasize this: http://tel.github.io/2014/07/23/types_of_data/