Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> How is Maybe not morally equivalent to a conditional?

Maybe is a way to represent conditionals that is amenable to higher order patterns. if-then-else conditionals are simply that, whereas Maybe is amenable to Monad, Monoid, and Applicative functor laws. So when we pull out mconcat or <> or mappend, we're actually talking about a higher order pattern.

As I mentioned in the article, we could take that same fizzbuzz code and modify it in many ways under the monoid rules. For example, a different harness in the main function could use Map String Integer and completely change the behavior with the same fizzbuzz function.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: