summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--events/src/Events/Spec/Eval.hs23
1 files changed, 12 insertions, 11 deletions
diff --git a/events/src/Events/Spec/Eval.hs b/events/src/Events/Spec/Eval.hs
index 24cfeb6..ddb32e4 100644
--- a/events/src/Events/Spec/Eval.hs
+++ b/events/src/Events/Spec/Eval.hs
@@ -49,21 +49,22 @@ evalExpr (EApp f a) = evalExpr $ beta a (evalExpr f)
49-- bindE :: (m a -> b) -> Expr m (a ': Ctx b) (Fin b) 49-- bindE :: (m a -> b) -> Expr m (a ': Ctx b) (Fin b)
50-- bindE f = liftE $ bindE . f 50-- bindE f = liftE $ bindE . f
51 51
52type family Ctx f where 52type family Ctx m f where
53 Ctx (a -> b) = (a ': Ctx b) 53 Ctx m (m a -> b) = (a ': Ctx m b)
54 Ctx a = '[] 54 Ctx m a = '[]
55 55
56type family Fin f where 56type family Fin m f where
57 Fin (a -> b) = Fin b 57 Fin m (m a -> b) = Fin m b
58 Fin a = a 58 Fin m (m a) = a
59 Fin m a = a
59 60
60class Bindable m b where 61class Bindable m b where
61 bindE :: (Val m a -> m b) -> Expr m (a ': Ctx b) (Fin b) 62 bindE :: (Val m a -> b) -> Expr m (a ': Ctx m b) (Fin m b)
62 63
63instance {-# OVERLAPS #-} ((Val m b) ~ (m b), Applicative m, Bindable m c) => Bindable m (b -> c) where 64instance ((Val m b) ~ (m b), Applicative m, Bindable m c) => Bindable m (m b -> c) where
64 bindE :: (Val m a -> m (b -> c)) -> Expr m (a ': b ': Ctx c) (Fin c) 65 bindE :: (Val m a -> m b -> c) -> Expr m (a ': b ': Ctx m c) (Fin m c)
65 bindE f = (EPri :: (Val m a -> Expr m (b ': Ctx c) (Fin c)) -> Expr m (a ': b ': Ctx c) (Fin c)) . ((bindE :: (Val m b -> m c) -> Expr m (b ': Ctx c) (Fin c)) . ) $ ((<*>) . f) 66 bindE f = (EPri :: (Val m a -> Expr m (b ': Ctx m c) (Fin m c)) -> Expr m (a ': b ': Ctx m c) (Fin m c)) . ((bindE :: (Val m b -> c) -> Expr m (b ': Ctx m c) (Fin m c)) . ) $ f
66 67
67instance (Val m b ~ m b, Ctx b ~ '[], Fin b ~ b) => Bindable m b where 68instance {-# OVERLAPPABLE #-} (Val m b ~ m b, Ctx m (m b) ~ '[], Fin m (m b) ~ b) => Bindable m (m b) where
68 bindE :: (Val m a -> Val m b) -> Expr m '[a] b 69 bindE :: (Val m a -> Val m b) -> Expr m '[a] b
69 bindE = EPri . (EVal .) 70 bindE = EPri . (EVal .)