Skip to content

Instantly share code, notes, and snippets.

@yangsu
Last active December 16, 2015 14:09
Show Gist options
  • Save yangsu/5446765 to your computer and use it in GitHub Desktop.
Save yangsu/5446765 to your computer and use it in GitHub Desktop.
Haskell Simple Monad
module Main where
data Position t = Position t deriving (Show)
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment