I\'ve been gradually learning Haskell, and even feel like I\'ve got a hang of monads. However, there\'s still a lot of more exotic stuff that I barely understand, like Arrows, A
You know all you need to go forth and write code. But if you're looking for more Haskell-y things to learn about, may I suggest:
data TTrue = TTrue
data FFalse = FFalse
class TypeLevelIf tf a b where type If tf a b weirdIfStatement :: tf -> a -> b -> tf a b
instance TypeLevelIf TTrue a b where type If TTrue a b = a weirdIfStatement TTrue a b = a
instance TypeLevelIf FFalse a b where type If FFalse a b = b weirdIfStatement FFalse a b = a
This gives you a function that behaves like an if
statement, but is able to return different types based on the truth value it is given.
If you're curious about type-level programming, type families provide one avenue into this topic.
Template Haskell. This is a huge subject. It gives you a power similar to macros in C, but with much more type safety.
Learn about some of the leading Haskell libraries. I can't count how many times parsec has enabled me to write an insanely useful utility quickly. dons periodically publishes a list of popular libraries on hackage; check it out.
Typeclasses like Monad
, Applicative
, Arrow
, Functor
are great and all, and even more great for changing how you think about code than necessarily the convenience of having functions generic over them. But there's a common misconception that the "next step" in Haskell is learning about more typeclasses and ways of structuring control flow. The next step is in deciding what you want to write, and trying to write it, exploring what you need along the way.
And even if you understand Monads, that doesn't mean you've scratched the surface of what you can do with monadically structured code. Play with parser combinator libraries, or write your own. Explore why applicative notation is sometimes easier for them. Explore why limiting yourself to applicative parsers might be more efficient.
Look at logic or math problems and explore ways of implementing backtracking -- depth-first, breadth-first, etc. Explore the difference between ListT and LogicT and ChoiceT. Take a look at continuations.
Or do something completely different!
Contribute to GHC!