File tree Expand file tree Collapse file tree 1 file changed +39
-2
lines changed Expand file tree Collapse file tree 1 file changed +39
-2
lines changed Original file line number Diff line number Diff line change 77{-# language ScopedTypeVariables #-}
88{-# language StandaloneDeriving #-}
99{-# language TemplateHaskell #-}
10+ {-# language TupleSections #-}
1011module Language.Elm.Expression where
1112
1213import Bound
@@ -44,8 +45,44 @@ instance Applicative Expression where
4445 (<*>) = ap
4546
4647instance Monad Expression where
47- (>>=) =
48- flip $ bind Global
48+ expression >>= f =
49+ case expression of
50+ Var v ->
51+ f v
52+
53+ Global g ->
54+ Global g
55+
56+ App g x ->
57+ App (g >>= f) (x >>= f)
58+
59+ Let e s ->
60+ Let (e >>= f) (s >>>= f)
61+
62+ Lam e ->
63+ Lam (e >>>= f)
64+
65+ Record fields ->
66+ Record (map (fmap (>>= f)) fields)
67+
68+ Proj fieldName ->
69+ Proj fieldName
70+
71+ Case e patterns ->
72+ Case (e >>= f) (map (fmap (>>>= f)) patterns)
73+
74+ List es ->
75+ List (map (>>= f) es)
76+
77+ String text ->
78+ String text
79+
80+ Int integer ->
81+ Int integer
82+
83+ Float double ->
84+ Float double
85+
4986
5087bind :: forall v v' . (Name. Qualified -> Expression v' ) -> (v -> Expression v' ) -> Expression v -> Expression v'
5188bind global var expression =
You can’t perform that action at this time.
0 commit comments