@@ -53,6 +53,8 @@ strHead x = foreign_ tyChar "strHead" [(x, tyString)]
53strTail x = foreign_ tyString "strTail" [(x, tyString)]
53strTail x = foreign_ tyString "strTail" [(x, tyString)]
54strCons x xs = foreign_ tyString "strCons" [(x, tyChar), (xs, tyString)]
54strCons x xs = foreign_ tyString "strCons" [(x, tyChar), (xs, tyString)]
55strRev x = foreign_ tyString "strrev" [(x, tyString)]
55strRev x = foreign_ tyString "strrev" [(x, tyString)]
56+strEq x y = foreign_ tyInt "streq" [(x, tyString), (y, tyString)]
57+strLt x y = foreign_ tyInt "strlt" [(x, tyString), (y, tyString)]
57primitives =
59primitives =
58 -- operators
60 -- operators
@@ -74,6 +76,16 @@ primitives =
74 (eOp E.gt_),
76 (eOp E.gt_),
75 Prim (UN "prim__gteInt") (ty [IType, IType] IType) 2 (biBin (>=))
77 Prim (UN "prim__gteInt") (ty [IType, IType] IType) 2 (biBin (>=))
76 (eOp E.gte_),
78 (eOp E.gte_),
79+ Prim (UN "prim__eqChar") (ty [ChType, ChType] IType) 2 (bcBin (==))
81+ Prim (UN "prim__ltChar") (ty [ChType, ChType] IType) 2 (bcBin (<))
83+ Prim (UN "prim__lteChar") (ty [ChType, ChType] IType) 2 (bcBin (<=))
85+ Prim (UN "prim__gtChar") (ty [ChType, ChType] IType) 2 (bcBin (>))
87+ Prim (UN "prim__gteChar") (ty [ChType, ChType] IType) 2 (bcBin (>=))
77 Prim (UN "prim__addBigInt") (ty [BIType, BIType] BIType) 2 (bBin (+))
89 Prim (UN "prim__addBigInt") (ty [BIType, BIType] BIType) 2 (bBin (+))
78 (eOpFn tyBigInt tyBigInt "addBig"),
90 (eOpFn tyBigInt tyBigInt "addBig"),
79 Prim (UN "prim__subBigInt") (ty [BIType, BIType] BIType) 2 (bBin (-))
91 Prim (UN "prim__subBigInt") (ty [BIType, BIType] BIType) 2 (bBin (-))
@@ -112,6 +124,10 @@ primitives =
112 (eOp E.gteF_),
124 (eOp E.gteF_),
113 Prim (UN "prim__concat") (ty [StrType, StrType] StrType) 2 (sBin (++))
125 Prim (UN "prim__concat") (ty [StrType, StrType] StrType) 2 (sBin (++))
114 ([E.name "x", E.name "y"], (fun "append") @@ fun "x" @@ fun "y"),
126 ([E.name "x", E.name "y"], (fun "append") @@ fun "x" @@ fun "y"),
127+ Prim (UN "prim__eqString") (ty [StrType, StrType] IType) 2 (bsBin (==))
128+ ([E.name "x", E.name "y"], strEq (fun "x") (fun "y")),
129+ Prim (UN "prim__ltString") (ty [StrType, StrType] IType) 2 (bsBin (<))
130+ ([E.name "x", E.name "y"], strLt (fun "x") (fun "y")),
115 -- Conversions
131 -- Conversions
116 Prim (UN "prim__strToInt") (ty [StrType] IType) 1 (c_strToInt)
132 Prim (UN "prim__strToInt") (ty [StrType] IType) 1 (c_strToInt)
117 ([E.name "x"], strToInt (fun "x")),
133 ([E.name "x"], strToInt (fun "x")),
@@ -166,6 +182,15 @@ bfBin op [VConstant (Fl x), VConstant (Fl y)] = let i = (if op x y then 1 else 0
166 Just $ VConstant (I i)
182 Just $ VConstant (I i)
167bfBin _ _ = Nothing
183bfBin _ _ = Nothing
185+bcBin op [VConstant (Ch x), VConstant (Ch y)] = let i = (if op x y then 1 else 0) in
186+ Just $ VConstant (I i)
189+bsBin op [VConstant (Str x), VConstant (Str y)]
190+ = let i = (if op x y then 1 else 0) in
191+ Just $ VConstant (I i)
169sBin op [VConstant (Str x), VConstant (Str y)] = Just $ VConstant (Str (op x y))
194sBin op [VConstant (Str x), VConstant (Str y)] = Just $ VConstant (Str (op x y))
170sBin _ _ = Nothing
195sBin _ _ = Nothing