News for hackers. Stuff that matters.
[deleted]
Re:Deconstructing Functional Programming [video] by thinkpad20 on Friday December 20, 2013 @12:40PM (#6942706)
As someone who went through the same thing, my best advice is, don't read monad tutorials; just write monadic code. Reading too much can just be confusing and might make you feel like an idiot for not understanding it yet. In the beginning it might be weird, and you'll no doubt spend a great deal of time puzzling over obscure type errors, but it will eventually become intuitive, if you're actually writing code and working through it. Haskell is a theory-heavy language, but it's still a programming language, which is actually meant to do things. There's no substitute for experience.

Perhaps try going through "Write Yourself a Scheme" which uses monads from the outset, or look at "Monad Transformers Step-by-Step" (be warned though, it starts off mostly simple but then makes a sudden and somewhat jarring leap forward). Try to implement a stack with "push" and "pop" monadic operations (use this as a starting point: http://brandon.si/code/the-state-monad-a-tutorial-for-the-co... but keep in mind it's much more important to WRITE the code, and play with it, than to try to understand how it's all working just via explanations).

For what it's worth, here's my ten cent explanation of monads:

A monad is interface for containers. A type which implements this interface must have two methods, `return` which inserts an object into a container, and `bind` which says what should happen when we use the value in one container to create a new container.

Re:Deconstructing Functional Programming [video] by charlieflowers on Friday December 20, 2013 @10:50PM (#6945655)
I know it's a running joke how many monad tutorials and analogies there are. And I get the humor and very much enjoy the joke.

However, I was able to gain a solid understanding of monads by working through a number of those tutorials. Over that period of time, I came to suspect, and then eventually confirm, that I had previously created my own monad for a particular purpose in C# (my case was checking the value of something in an XML tree, an attribute of an element of an element of an element, where the attribute might be missing, or its parent element might be missing, or its parent, and so on. So it was much like Bracha's ".?" sugar example).

So, monad tutorials actually (eventually) made the concept clear to me. It's fun to make fun of them, and they deserve to take a little heat, but we have to give them credit where credit is due too.

Re:Deconstructing Functional Programming [video] by platz on Friday December 20, 2013 @10:39PM (#6945621)
The container analogy does break down in some instances. For example, using monads to model a workflow. I've come to accept 'Computational Context' as the best descriptor so far.
Re:Deconstructing Functional Programming [video] by paulkoer on Friday December 20, 2013 @12:31PM (#6942631)
I recommend: http://blog.sigfpe.com/2006/08/you-could-have-invented-monad...

But in the end I think for most people 'understanding' the concept of monads is just something that is not to be had within a couple of hours. It takes a little bit of patience thinking about them and using them for a while.

Re:Deconstructing Functional Programming [video] by agumonkey on Saturday December 21, 2013 @01:46AM (#6946013)
My first non haskell monad tutorial was this dorophone.blogspot.com/2011/04/deep-emacs-part-1.html‎

very 'operational', zero magic, good to get your hands dirty.

Dans' tutorial you linked is one of my favorite too.

Re:Deconstructing Functional Programming [video] by lmm on Friday December 20, 2013 @12:58PM (#6942850)
Re:Deconstructing Functional Programming [video] by charlieflowers on Friday December 20, 2013 @10:53PM (#6945661)
The core problem seems to be that we just don't (yet) have good words for this particular space of abstractions. Many programmers have thought about or solved the same problem monads address, but they haven't mentally labelled the concept, and we certainly have agreed as an industry on these labels. So we're all struggling to try to talk about some things we don't have terms for.
Re:Deconstructing Functional Programming [video] by qu1j0t3 on Monday December 23, 2013 @11:35PM (#6958235)
"The core problem seems to be that we just don't (yet) have good words for this particular space of abstractions"

How about "functor," "monad," "applicative" etc.?

Re:Deconstructing Functional Programming [video] by chongli on Friday December 20, 2013 @12:18PM (#6942523)
You've probably read too many monad tutorials that make terrible analogies. Try reading this instead:

http://dev.stephendiehl.com/hask/

Re:Deconstructing Functional Programming [video] by carterschonwald on Friday December 20, 2013 @12:24PM (#6942580)
yes, i can comfortably say "any doc by stephen diehl is worth reading" :)
[deleted]
Re:Deconstructing Functional Programming [video] by chongli on Friday December 20, 2013 @12:32PM (#6942639)
Why isn't it helpful to you?
Re:Deconstructing Functional Programming [video] by pramalin on Friday December 20, 2013 @12:39PM (#6942691)
Have you read "Monads are Elephants"? That helped me a great deal.

http://james-iry.blogspot.com/2007/09/monads-are-elephants-p...