No title

Anonymous Coward 2018-03-05 20:25:16.699033 UTC

1type TimeDiff = Double
2
3newtype A e w s = A
4 { view :: s
5 , poke :: w -> e -> A e w s
6 , shift :: TimeDiff -> A e w s
7 , eta :: TimeDiff }
8
9data Cmd = Zero | One | Plus | Clear
10
11calculator :: A Cmd w (Int,Int)
12calculator = start where
13 loop r1 r2 = self where
14 self = A (r1,r2) on elapse never
15 on _ Zero = loop r1 (r2 * 2)
16 on _ One = loop r1 (r2 * 2 + 1)
17 on _ Plus = loop (r1 + r2) 0
18 on _ Clear = loop 0 0
19 elapse dt = self
20 start = loop 0 0
21 never = 1/0