diff --git a/src/Bergamot/Syntax.elm b/src/Bergamot/Syntax.elm index 403fefa..5b2edb0 100644 --- a/src/Bergamot/Syntax.elm +++ b/src/Bergamot/Syntax.elm @@ -24,6 +24,7 @@ unUnificationVar (MkUnificationVar s) = s type Term a = IntLit Int + | FloatLit Float | StringLit String | Call Name (List (Term a)) | Var a @@ -32,6 +33,7 @@ map : (a -> b) -> Term a -> Term b map f t = case t of IntLit i -> IntLit i + FloatLit ft -> FloatLit ft StringLit s -> StringLit s Call n ts -> Call n (List.map (map f) ts) Var a -> Var (f a) @@ -40,6 +42,7 @@ andThen : (a -> Term b) -> Term a -> Term b andThen f t = case t of IntLit i -> IntLit i + FloatLit ft -> FloatLit ft StringLit s -> StringLit s Call n ts -> Call n (List.map (andThen f) ts) Var a -> f a @@ -79,6 +82,7 @@ instantiate : Term Metavariable -> InstantiationState -> (Term UnificationVar, I instantiate mt is = case mt of IntLit i -> (IntLit i, is) + FloatLit f -> (FloatLit f, is) StringLit s -> (StringLit s, is) Call n mts -> Tuple.mapFirst (Call n) (instantiateList mts is) Var mv -> Tuple.mapFirst Var (metavariable mv is) @@ -157,6 +161,7 @@ occurs : Set String -> UnificationState -> Term UnificationVar -> Bool occurs vars us t = case t of IntLit _ -> False + FloatLit _ -> False StringLit _ -> False Call n ts -> List.any (occurs vars us) ts Var (MkUnificationVar v) -> if Set.member v vars then True else @@ -180,6 +185,7 @@ unify : Term UnificationVar -> Term UnificationVar -> UnificationState -> Maybe unify t1 t2 us = case (t1, t2) of (IntLit i1, IntLit i2) -> if i1 == i2 then Just (t1, us) else Nothing + (FloatLit f1, FloatLit f2) -> if f1 == f2 then Just (t1, us) else Nothing (StringLit s1, StringLit s2) -> if s1 == s2 then Just (t1, us) else Nothing (Call n1 ts1, Call n2 ts2) -> if n1 == n2 @@ -196,6 +202,7 @@ reify : Term UnificationVar -> UnificationState -> Term UnificationVar reify t us = case t of IntLit i -> IntLit i + FloatLit f -> FloatLit f StringLit s -> StringLit s Call n ts -> Call n (List.map (\tp -> reify tp us) ts) Var v ->