Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Brian Beckman: Don't fear the Monad
Nov 24, 2007 at 12:50 AMI no longer "fear" monads, but I am now quite perplexed about why they're even worth discussing! I am willing to accept that I'm totally missing the boat here, but please do help me understand...
Let's see if I can paraphrase one example from the video:
we have two functions:
f: a -> Ma
g: a -> Ma
and we wish to compose them, but alas one cannot pipe output from one straight into the other. So we define a "bind operator" that lets us do this; we use some fancy formatting and rules to describe a lamda function that inside it deals with the different input/output types in order to get the two functions interacting happily.
Er, do we need functional programming to do this?
It seems like in any language/paradigm that I can very simply create a new "ordinary" function:
h: Ma -> a
responsible for stripping off the M and compose the two quite quickly. Is this approach not equivalent? What makes "bind" so special? For example:
struct M { int data; foo meta; }
M f( int ) { ... }
M g( int ) { ... }
int h( M ) {... }
M compose_fg( int x ) { return g( h ( f( x ) ) ); }
So where have I gone wrong