Created
November 12, 2009 03:41
-
-
Save jutememo/232571 to your computer and use it in GitHub Desktop.
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
module Counter where | |
-- カウンタを表わす型 | |
data Counter a = Counter { val -- 値 | |
, step :: a -- 増分 | |
} deriving Show | |
-- カウンタの値を増加させる | |
next :: Num a => Counter a -> (a, Counter a) | |
next (Counter v s) = let v' = v + s | |
in (v', Counter v' s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment