Skip to content

Instantly share code, notes, and snippets.

@folone
Created March 6, 2012 15:29
Show Gist options
  • Save folone/1986803 to your computer and use it in GitHub Desktop.
Save folone/1986803 to your computer and use it in GitHub Desktop.
Illustration to The Monad Reader issue 17, The Reader Monad and Abstraction Elimination by Petr Pudlak
import Control.Applicative
main = print $ answer succ 0 where
one = pure <*> (pure :: a -> b -> a)
inc = (<*>) ((<*>) <$> pure)
mul = (<*>) <$> pure
h = mul <*> inc
answer = h . h . h $ one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment