@@ -16,21 +16,37 @@ ty [] x = Constant x
1616ty (t:ts) x = Bind (MN 0 "T") (Pi (Constant t)) (ty ts x)
1717
1818primitives =
19− [Prim (UN ["prim__addInt"]) (ty [IType, IType] IType) 2 (vBin (+)),
20− Prim (UN ["prim__subInt"]) (ty [IType, IType] IType) 2 (vBin (-)),
21− Prim (UN ["prim__mulInt"]) (ty [IType, IType] IType) 2 (vBin (*)),
22− Prim (UN ["prim__divInt"]) (ty [IType, IType] IType) 2 (vBin (div)),
23− Prim (UN ["prim__eqInt"]) (ty [IType, IType] IType) 2 (bBin (==)),
24− Prim (UN ["prim__ltInt"]) (ty [IType, IType] IType) 2 (bBin (<)),
25− Prim (UN ["prim__lteInt"]) (ty [IType, IType] IType) 2 (bBin (<=)),
26− Prim (UN ["prim__gtInt"]) (ty [IType, IType] IType) 2 (bBin (>)),
27− Prim (UN ["prim__gteInt"]) (ty [IType, IType] IType) 2 (bBin (>=))
19+ [Prim (UN ["prim__addInt"]) (ty [IType, IType] IType) 2 (iBin (+)),
20+ Prim (UN ["prim__subInt"]) (ty [IType, IType] IType) 2 (iBin (-)),
21+ Prim (UN ["prim__mulInt"]) (ty [IType, IType] IType) 2 (iBin (*)),
22+ Prim (UN ["prim__divInt"]) (ty [IType, IType] IType) 2 (iBin (div)),
23+ Prim (UN ["prim__eqInt"]) (ty [IType, IType] IType) 2 (biBin (==)),
24+ Prim (UN ["prim__ltInt"]) (ty [IType, IType] IType) 2 (biBin (<)),
25+ Prim (UN ["prim__lteInt"]) (ty [IType, IType] IType) 2 (biBin (<=)),
26+ Prim (UN ["prim__gtInt"]) (ty [IType, IType] IType) 2 (biBin (>)),
27+ Prim (UN ["prim__gteInt"]) (ty [IType, IType] IType) 2 (biBin (>=)),
28+ Prim (UN ["prim__addFloat"]) (ty [FlType, FlType] FlType) 2 (fBin (+)),
29+ Prim (UN ["prim__subFloat"]) (ty [FlType, FlType] FlType) 2 (fBin (-)),
30+ Prim (UN ["prim__mulFloat"]) (ty [FlType, FlType] FlType) 2 (fBin (*)),
31+ Prim (UN ["prim__divFloat"]) (ty [FlType, FlType] FlType) 2 (fBin (/)),
32+ Prim (UN ["prim__eqFloat"]) (ty [FlType, FlType] IType) 2 (bfBin (==)),
33+ Prim (UN ["prim__ltFloat"]) (ty [FlType, FlType] IType) 2 (bfBin (<)),
34+ Prim (UN ["prim__lteFloat"]) (ty [FlType, FlType] IType) 2 (bfBin (<=)),
35+ Prim (UN ["prim__gtFloat"]) (ty [FlType, FlType] IType) 2 (bfBin (>)),
36+ Prim (UN ["prim__gteFloat"]) (ty [FlType, FlType] IType) 2 (bfBin (>=))
2837 ]
2938
30−vBin op [VConstant (I x), VConstant (I y)] = Just $ VConstant (I (op x y))
31−vBin _ _ = Nothing
39+iBin op [VConstant (I x), VConstant (I y)] = Just $ VConstant (I (op x y))
40+iBin _ _ = Nothing
3241
33−bBin op = vBin (\x y -> if (op x y) then 1 else 0)
42+biBin op = iBin (\x y -> if (op x y) then 1 else 0)
43+
44+fBin op [VConstant (Fl x), VConstant (Fl y)] = Just $ VConstant (Fl (op x y))
45+fBin _ _ = Nothing
46+
47+bfBin op [VConstant (Fl x), VConstant (Fl y)] = let i = (if op x y then 1 else 0) in
48+ Just $ VConstant (I i)
49+bfBin _ _ = Nothing
3450
3551elabPrim :: Prim -> Idris ()
3652elabPrim (Prim n ty i def) = updateContext (addOperator n ty i def)