module PatternMatching where
import qualified JS.Ast as JS
import Wave.Ast
data PatResult = PatResult
{ PatResult -> [Expr]
conditions :: [JS.Expr],
PatResult -> [(Var, Expr)]
matchers :: [(Var, JS.Expr)]
}
instance Semigroup PatResult where
<> :: PatResult -> PatResult -> PatResult
(<>) (PatResult [Expr]
c1 [(Var, Expr)]
m1) (PatResult [Expr]
c2 [(Var, Expr)]
m2) =
[Expr] -> [(Var, Expr)] -> PatResult
PatResult ([Expr]
c1 [Expr] -> [Expr] -> [Expr]
forall a. Semigroup a => a -> a -> a
<> [Expr]
c2) ([(Var, Expr)]
m1 [(Var, Expr)] -> [(Var, Expr)] -> [(Var, Expr)]
forall a. Semigroup a => a -> a -> a
<> [(Var, Expr)]
m2)
instance Monoid PatResult where
mempty :: PatResult
mempty = [Expr] -> [(Var, Expr)] -> PatResult
PatResult [] []