@@ -53,6 +53,8 @@ strHead x = foreign_ tyChar "strHead" [(x, tyString)]
5353strTail x = foreign_ tyString "strTail" [(x, tyString)]
5454strCons x xs = foreign_ tyString "strCons" [(x, tyChar), (xs, tyString)]
5555strRev 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)]
5658
5759primitives =
5860 -- operators
@@ -74,6 +76,16 @@ primitives =
7476 (eOp E.gt_),
7577 Prim (UN "prim__gteInt") (ty [IType, IType] IType) 2 (biBin (>=))
7678 (eOp E.gte_),
79+ Prim (UN "prim__eqChar") (ty [ChType, ChType] IType) 2 (bcBin (==))
80+ (eOp E.eq_),
81+ Prim (UN "prim__ltChar") (ty [ChType, ChType] IType) 2 (bcBin (<))
82+ (eOp E.lt_),
83+ Prim (UN "prim__lteChar") (ty [ChType, ChType] IType) 2 (bcBin (<=))
84+ (eOp E.lte_),
85+ Prim (UN "prim__gtChar") (ty [ChType, ChType] IType) 2 (bcBin (>))
86+ (eOp E.gt_),
87+ Prim (UN "prim__gteChar") (ty [ChType, ChType] IType) 2 (bcBin (>=))
88+ (eOp E.gte_),
7789 Prim (UN "prim__addBigInt") (ty [BIType, BIType] BIType) 2 (bBin (+))
7890 (eOpFn tyBigInt tyBigInt "addBig"),
7991 Prim (UN "prim__subBigInt") (ty [BIType, BIType] BIType) 2 (bBin (-))
@@ -112,6 +124,10 @@ primitives =
112124 (eOp E.gteF_),
113125 Prim (UN "prim__concat") (ty [StrType, StrType] StrType) 2 (sBin (++))
114126 ([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")),
115131 -- Conversions
116132 Prim (UN "prim__strToInt") (ty [StrType] IType) 1 (c_strToInt)
117133 ([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
166182 Just $ VConstant (I i)
167183bfBin _ _ = Nothing
168184
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)
187+bcBin _ _ = Nothing
188+
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)
192+bsBin _ _ = Nothing
193+
169194sBin op [VConstant (Str x), VConstant (Str y)] = Just $ VConstant (Str (op x y))
170195sBin _ _ = Nothing
171196