Live data from Hacker News

The Monad Challenges: Jump start your understanding of monads

mightybyte.github.io

31–40 of 51 posts

Re: The Monad Challenges: Jump start your understanding of monads

#31

Cool tutorials. I think it's much more effective to start with learning functors and applicatives before monads. I'm surprised at the number of tutorials aimed at teaching people monads who don't yet understand the more basic type classes.

>I think it's much more effective to start with learning functors and applicatives before monads. I'm surprised at the number of tutorials aimed at teaching people monads who don't yet understand the more basic type classes.

I agree, we did this in our book. We actually decomposed it pretty aggressively - http://haskellbook.com/progress.html

There is a point at which you can just follow along with the types as you learn Monads, but it's not terribly satisfying without context and still requires understanding _the types_. That's pretty hard to do if you aren't comfortable with higher kinded types and typeclasses. Functor and Applicative let you break the problem down a bit more. We do Monoid and Semigroup before Functor so they get accustomed to seemingly very abstract typeclasses before coping with higher kinded types + seemingly-abstract typeclass. Prior to _Monoid_, we explain kinds and higher kinded types.

This approach has made it so the book works a lot more effectively; frequently, but also makes it longer. Lots more code, examples, and exercises.

Re: The Monad Challenges: Jump start your understanding of monads

#32
post #24

> Do I need to know Haskell? Yes. This is enough for me to reject this blogpost. No you don't need a specific language to implement any functionality that can be implemented by a turing-complete language. I watched Crockford's monad talk [1]. He used javascript. The only problem with that talk is that he spent about 10 seconds or less explaining what a monad is (and the rest of the talk on implementation issues and h…

Dude, fine. But the author wrote the tutorial with those assumptions, he's just trying to help you out bro!

Re: The Monad Challenges: Jump start your understanding of monads

#35
post #24

> Do I need to know Haskell? Yes. This is enough for me to reject this blogpost. No you don't need a specific language to implement any functionality that can be implemented by a turing-complete language. I watched Crockford's monad talk [1]. He used javascript. The only problem with that talk is that he spent about 10 seconds or less explaining what a monad is (and the rest of the talk on implementation issues and h…

You need to know Haskell to complete the exercises, not to understand Monads.

Re: The Monad Challenges: Jump start your understanding of monads

#36
post #29
post #24

> Do I need to know Haskell? Yes. This is enough for me to reject this blogpost. No you don't need a specific language to implement any functionality that can be implemented by a turing-complete language. I watched Crockford's monad talk [1]. He used javascript. The only problem with that talk is that he spent about 10 seconds or less explaining what a monad is (and the rest of the talk on implementation issues and h…

It's true that you don't need to know Haskell in order to learn about monads, but Haskell is a perfectly reasonable language in which to write a monad introduction. Haskell is good for learning about monads for the same reasons monads tend to be heavily used in Haskell, but not in other languages. Monads are both part of Haskell's standard library, and have very useful special syntax (do-notation). Writing out monadi…

>Writing out monadic code explicitly gets to be a huge pain when using monads in another language.

Couldn't any other language have a syntax like

    thing.do(\x -> other thing(x)).do(
    \x -> yet another thing(x)).do(
    a function).do(
    more stuff).do(
    etc)
And then replace "\x -> whatever" with the local language's lambda syntax. The only time you get the painful nested parens is if you want

    thing.do(
    \x -> f(x).do(
    \y -> g(x,y)))
It's not too terribly bad.

Re: The Monad Challenges: Jump start your understanding of monads

#37

Cool tutorials. I think it's much more effective to start with learning functors and applicatives before monads. I'm surprised at the number of tutorials aimed at teaching people monads who don't yet understand the more basic type classes.

Hi, author here. Thanks for the feedback. I definitely get your point. I thought about it and there are a few reasons I went the way I did. 1. I decided that functors are straightforward enough to not really need significant special treatment. 2. Applicatives are much less commonly used than monads (see IO etc), so I thought it would be more desirable to hit the bigger use case first without getting side tracked on applicatives. 3. I feel this progression kind of has history on its side since Applicative wasn't a super class of Monad until very recently.

That being said, I'm very open to being convinced otherwise and pull requests carry a lot of weight with me. If someone reorganized the material in the way you suggest and it had a nice flow, there's a decent chance I would accept it.

Re: The Monad Challenges: Jump start your understanding of monads

#38
post #24

> Do I need to know Haskell? Yes. This is enough for me to reject this blogpost. No you don't need a specific language to implement any functionality that can be implemented by a turing-complete language. I watched Crockford's monad talk [1]. He used javascript. The only problem with that talk is that he spent about 10 seconds or less explaining what a monad is (and the rest of the talk on implementation issues and h…

Hi, I'm sorry you feel that way. Maybe you just aren't my target audience. That being said, Crockford's explanation of monads in that talk was overly simplistic and misses much of the point of the benefit that you get from them in a language like Haskell. And if we're being honest here I think it's safe to say that most programmers wouldn't have even heard of monads if it wasn't for Haskell. I gave a talk at the NY Haskell meetup a few years ago that specifically addresses Crockford's talk in a little more detail [1]. That talk might be about the level you're looking for. There is some Haskell code, but most of the talk should make sense to someone not familiar with Haskell.

[1] https://vimeo.com/59215336

Re: The Monad Challenges: Jump start your understanding of monads

#39

I have Haskell experience and would love to do these exercises, but I am struggling with the environment. For example, Set1 tells me to make a function fiveRands and then "check my answers;" how do I do that? I know enough Haskell to do something like: main = putStrLn $ show fiveRands but putStrLn is not part of MCPrelude so this doesn't compile, and the instructions say explicitly "Do not import any other modules."…

Hi, I was assuming that people would do their playing around and answer checking in ghci. MCPrelude does not export putStrLn because it is an IO function, which is a monad and I specifically wanted to hide all the prelude's monad stuff. I suggest loading your file in ghci with "ghci Set1.hs". Then you can just type "fiveRands" at the ghci prompt and it will show you the values.
Post reply on HN