Created
October 24, 2011 17:50
-
-
Save raichoo/1309631 to your computer and use it in GitHub Desktop.
fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Applicative | |
import Control.Monad.Fix | |
data CounterRep = CounterRep { x :: Int } | |
data Counter = Counter { get :: Int, | |
set :: Int -> Counter, | |
inc :: Counter } | |
counterClass = \rep -> | |
\this -> | |
Counter { get = x rep, | |
set = newCounter, | |
inc = newCounter $ (get this) + 1 } | |
newCounter x = fix (counterClass $ CounterRep x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment