Talk:Monad (functional programming): Difference between revisions

Content deleted Content added
Immerc (talk | contribs)
No edit summary
Line 31:
 
Shouldn't this either be renamed to something like "Monads in Haskell" with a link to understanding Haskell, or have the equations written in a common mathematical way?
 
:If I understand correctly, monads are containers for values: for example, a monad value like "Just 5" contains the value 5. The return function "wraps" a value inside a monad, the fmap function allows another function to "look inside" a monad value, and it looks like join turns a value like Just (Just 5) into Just 5, or [[3]] into [3]. A few examples:
 
return 3 = either [3] or Just 3 -- "Wrap" the value 3 with a monad
fmap (+1) [3,2,4] = [4,3,5] -- (+1) is the incrementor function, and it is allowed to "peek inside" this list to increment everything inside it.
fmap (+1) (Just 5) = Just 6 -- Peeking inside a "Just" value.
join Maybe (Maybe 7) = Maybe 7 -- "Joining" these two Maybe's into one
join <nowiki>[[2]]</nowiki> = [2] -- Joining a listifier with a listifier
 
:Is this clear enough? --[[User:67.172.99.160|67.172.99.160]] 02:09, 3 December 2005 (UTC)