diff options
author | Camil Staps | 2021-01-04 20:27:45 +0100 |
---|---|---|
committer | Camil Staps | 2021-01-04 20:27:45 +0100 |
commit | 88de5784428bec9a4b32bdf447c160da29b3745e (patch) | |
tree | 4b5a52c8fe2560e98aca0d74ec8dcd5cb09b2b70 /Sil/Types.icl | |
parent | Fix error reporting for illegal command line arguments (diff) |
Make up to date
Diffstat (limited to 'Sil/Types.icl')
-rw-r--r-- | Sil/Types.icl | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/Sil/Types.icl b/Sil/Types.icl index 829b82d..083e3be 100644 --- a/Sil/Types.icl +++ b/Sil/Types.icl @@ -24,7 +24,7 @@ import Sil.Util.Parser import Sil.Util.Printer derive gEq Type -instance == Type where == a b = gEq{|*|} a b +instance == Type where (==) a b = gEq{|*|} a b instance toString Type where @@ -58,18 +58,18 @@ typeSize (TList _) = {zero & asize=1} , btypes = abort "btypes after -~\r\n" } -instance zero TypeResolver where zero = const Nothing +instance zero TypeResolver where zero = const ?None instance type Function where - type res f = Just $ Ok $ foldr (-->) f.f_type [a.arg_type \\ a <- f.f_args] + type res f = ?Just $ Ok $ foldr (-->) f.f_type [a.arg_type \\ a <- f.f_args] instance type Expression where type res (Name _ n) = type res n type res (Literal _ lit) = case lit of - BLit _ -> Just $ Ok TBool - ILit _ -> Just $ Ok TInt + BLit _ -> ?Just $ Ok TBool + ILit _ -> ?Just $ Ok TInt type res (App p n args) = mapM (type res) args >>= \ats -> res n >>= \ft -> pure @@ -94,19 +94,19 @@ where ( top >>= \top -> te1 >>= \te1 -> te2 >>= \te2 -> foldM (tryApply p) top [te1,te2]) - type res e=:(List _ (Just t) es) = + type res e=:(List _ (?Just t) es) = mapM (type res) es >>= \tes -> pure (sequence tes >>= \tes -> case [(e,t`) \\ e <- es & t` <- tes | t <> t`] of [(e`,t`):_] -> Error $ C_TypeMisMatch t e` t` [] -> Ok $ TList t) - type res (List _ Nothing []) = Nothing - type res e=:(List _ Nothing es) = + type res (List _ ?None []) = ?None + type res e=:(List _ ?None es) = mapM (type res) es >>= \tes -> pure (sequence tes >>= \tes -> case removeDup tes of [t] -> Ok $ TList t [_:_] -> Error $ C_CouldNotDeduceType e) type res e=:(Tuple _ n es) - | n > 32 = Just $ Error $ T_TooHighTupleArity (errpos e) n + | n > 32 = ?Just $ Error $ T_TooHighTupleArity (errpos e) n | otherwise = mapM (type res) es >>= \ats -> pure (sequence ats >>= pure o TTuple n) type res fe=:(Field _ f e) @@ -141,21 +141,21 @@ instance type Name where type res n = res n instance type Op1 where - type _ Neg = Just $ Ok $ TInt --> TInt - type _ Not = Just $ Ok $ TBool --> TBool + type _ Neg = ?Just $ Ok $ TInt --> TInt + type _ Not = ?Just $ Ok $ TBool --> TBool instance type Op2 where - type _ Add = Just $ Ok $ TInt --> TInt --> TInt - type _ Sub = Just $ Ok $ TInt --> TInt --> TInt - type _ Mul = Just $ Ok $ TInt --> TInt --> TInt - type _ Div = Just $ Ok $ TInt --> TInt --> TInt - type _ Rem = Just $ Ok $ TInt --> TInt --> TInt - type _ Equals = Just $ Ok $ TInt --> TInt --> TBool - type _ Unequals = Just $ Ok $ TInt --> TInt --> TBool - type _ CmpLe = Just $ Ok $ TInt --> TInt --> TBool - type _ CmpGe = Just $ Ok $ TInt --> TInt --> TBool - type _ CmpLt = Just $ Ok $ TInt --> TInt --> TBool - type _ CmpGt = Just $ Ok $ TInt --> TInt --> TBool - type _ LogOr = Just $ Ok $ TBool --> TBool --> TBool - type _ LogAnd = Just $ Ok $ TBool --> TBool --> TBool + type _ Add = ?Just $ Ok $ TInt --> TInt --> TInt + type _ Sub = ?Just $ Ok $ TInt --> TInt --> TInt + type _ Mul = ?Just $ Ok $ TInt --> TInt --> TInt + type _ Div = ?Just $ Ok $ TInt --> TInt --> TInt + type _ Rem = ?Just $ Ok $ TInt --> TInt --> TInt + type _ Equals = ?Just $ Ok $ TInt --> TInt --> TBool + type _ Unequals = ?Just $ Ok $ TInt --> TInt --> TBool + type _ CmpLe = ?Just $ Ok $ TInt --> TInt --> TBool + type _ CmpGe = ?Just $ Ok $ TInt --> TInt --> TBool + type _ CmpLt = ?Just $ Ok $ TInt --> TInt --> TBool + type _ CmpGt = ?Just $ Ok $ TInt --> TInt --> TBool + type _ LogOr = ?Just $ Ok $ TBool --> TBool --> TBool + type _ LogAnd = ?Just $ Ok $ TBool --> TBool --> TBool |