Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created November 12, 2009 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jutememo/232571 to your computer and use it in GitHub Desktop.
Save jutememo/232571 to your computer and use it in GitHub Desktop.
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