Skip to content

Instantly share code, notes, and snippets.

@abuiles
Created December 17, 2009 02:52
Show Gist options
  • Save abuiles/258486 to your computer and use it in GitHub Desktop.
Save abuiles/258486 to your computer and use it in GitHub Desktop.
data Burrito a = Tortilla a | TortillaSola
class Monad (m a) where
return :: m a
m a >>= f :: m a -> (a -> m b) -> m b
..
ahora
instance Monad (Burrito a) where
return a= (envolver a)::Burrito a
Tortilla a >>=f = f a
TortillaSola >>= _ = TortillaSola
si.
envolver a = Tortilla a
ponerJalapeño :: a -> Burrito b
ponerJalapeño a = Tortilla (mezclar a jalapeño)
#podriamos hacer un binding...
burritoDePolloConJalapeño = ponerJalapeño =<< return pollo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment