7 import Control.Applicative
10 :: In a b = In infixl 0 a b
13 (@) infixr 1 :: (v (a -> v b)) (v a) -> v b
14 \| :: ((v a) -> v b) -> v (a -> v b) | TC a & TC b & TC (v b)
18 lit :: a -> v a | toString, TC a
19 (+.) infixl 6 :: (v a) (v a) -> v a | + a
20 (-.) infixl 6 :: (v a) (v a) -> v a | - a
21 (*.) infixl 6 :: (v a) (v a) -> v a | * a
22 (/.) infixl 6 :: (v a) (v a) -> v a | / a
23 (==.) infix 4 :: (v a) (v a) -> v Bool | == a
24 If :: (v Bool) (v a) (v a) -> v a
28 lett :: ((v a) -> In (v a) (v b)) -> v b | TC a
32 :: St a = St (Env -> Either String (a, Env))
33 :: Env :== [(Int, Dynamic)]
34 instance Functor St where fmap f m = St $ fmap (appFst f) o evalSt m
35 instance pure St where pure x = St \s->Right (x, s)
36 instance <*> St where (<*>) mfa ma = ap mfa ma
39 bind ma a2mb = St \s->case evalSt ma s of
41 Right (a, s) = evalSt (a2mb a) s
43 get = St \s->Right (s, s)
44 put s = St \_->Right ((), s)
50 (+.) l r = (+) <$> l <*> r
51 (-.) l r = (-) <$> l <*> r
52 (*.) l r = (*) <$> l <*> r
53 (/.) l r = (/) <$> l <*> r
54 (==.) l r = (==) <$> l <*> r
55 If i t e = if` <$> i <*> t <*> e
59 (@) l r = l >>= \l->r >>= \r->l r
60 \| def = pure $ def o pure
64 lett def = length <$> get >>= \l->
65 let (x In y) = def $ get >>= \s->hd [d\\(x, d :: St a^)<-s | l == x]
66 in get >>= \s->put [(l, dynamic x):s] >>| y
72 initial_unification_environment [module: _SystemDynamic]
73 _initial_unification_environment [module: _SystemDynamic]
74 _f111;111 [module: bug]
75 <lambda>[line:65];38;90 [module: bug]
76 <case>[line:39];27;103 [module: bug]
78 <lambda>[line:39];23;11 [module: bug]
80 <lambda>[line:39];23;11 [module: bug]
83 <lambda>[line:39];23;11 [module: bug]
85 t1 = lett \id = (\| \x->x)
86 // In lett \fix = (\| \f->lett \x=f @ x In x)
87 In lett \fac = (\| \n->If (n ==. lit 0) (lit 1) (n *. (fac @ n -. lit 1)))
88 // In lett \facfix = (\| \n->(fix @ \| \fac-> \| \n->If (n ==. lit 0) (lit 1) (n *. (fac @ n -. lit 1))) @ n)
92 unify_ [module: _SystemDynamic]
93 unify_ [module: _SystemDynamic]
94 unify_ [module: _SystemDynamic]
95 unify_types [module: _SystemDynamic]
96 _unify [module: _SystemDynamic]
97 _f143;143 [module: bug]
98 <lambda>[line:65];38;101 [module: bug]
99 <case>[line:39];27;135 [module: bug]
101 <lambda>[line:39];23;22 [module: bug]
105 t2 = lett \id = (\| \x->x)
106 In lett \fix = (\| \f->lett \x=f @ x In x)
107 In lett \fac = (\| \n->If (n ==. lit 0) (lit 1) (n *. (fac @ n -. lit 1)))
108 In lett \facfix = (\| \n->(fix @ \| \fac-> \| \n->If (n ==. lit 0) (lit 1) (n *. (fac @ n -. lit 1))) @ n)
109 In facfix @ id @ lit 10