Skip to content

Instantly share code, notes, and snippets.

@freizl
Created June 30, 2012 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freizl/3021712 to your computer and use it in GitHub Desktop.
Save freizl/3021712 to your computer and use it in GitHub Desktop.
Bad or Incorrect Monad example?
module Main where
main = do let p = Position 0
print (treasureMap p == treasureMap2 p)
data Position t = Position t deriving (Show, Eq)
stagger (Position d) = Position (d + 2)
crawl (Position d) = Position (d + 1)
rtn x = x
x >>== f = f x
treasureMap pos = pos >>==
stagger >>==
stagger >>==
crawl >>==
rtn
treasureMap2 = crawl . stagger . stagger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment