@@ -35,6 +35,9 @@ intToStr x = foreign_ tyString "intToStr" [(x, tyInt)]
35strToFloat x = foreign_ tyFloat "strToFloat" [(x, tyString)]
35strToFloat x = foreign_ tyFloat "strToFloat" [(x, tyString)]
36floatToStr x = foreign_ tyString "floatToStr" [(x, tyFloat)]
36floatToStr x = foreign_ tyString "floatToStr" [(x, tyFloat)]
38+floatExp x = foreign_ tyFloat "exp" [(x, tyFloat)]
39+floatLog x = foreign_ tyFloat "log" [(x, tyFloat)]
38primitives =
41primitives =
39 -- operators
42 -- operators
40 [Prim (UN ["prim__addInt"]) (ty [IType, IType] IType) 2 (iBin (+))
43 [Prim (UN ["prim__addInt"]) (ty [IType, IType] IType) 2 (iBin (+))
@@ -83,7 +86,11 @@ primitives =
83 Prim (UN ["prim__strToFloat"]) (ty [StrType] FlType) 1 (c_strToFloat)
86 Prim (UN ["prim__strToFloat"]) (ty [StrType] FlType) 1 (c_strToFloat)
84 ([E.name "x"], strToFloat (fun "x")),
87 ([E.name "x"], strToFloat (fun "x")),
85 Prim (UN ["prim__floatToStr"]) (ty [FlType] StrType) 1 (c_floatToStr)
88 Prim (UN ["prim__floatToStr"]) (ty [FlType] StrType) 1 (c_floatToStr)
86− ([E.name "x"], floatToStr (fun "x"))
89+ ([E.name "x"], floatToStr (fun "x")),
90+ Prim (UN ["prim__floatExp"]) (ty [FlType] FlType) 1 (p_floatExp)
91+ ([E.name "x"], floatExp (fun "x")),
92+ Prim (UN ["prim__floatLog"]) (ty [FlType] FlType) 1 (p_floatLog)
93+ ([E.name "x"], floatLog (fun "x"))
89iBin op [VConstant (I x), VConstant (I y)] = Just $ VConstant (I (op x y))
96iBin op [VConstant (I x), VConstant (I y)] = Just $ VConstant (I (op x y))
@@ -111,6 +118,11 @@ c_floatToStr _ = Nothing
111c_strToFloat [VConstant (Str x)] = Just $ VConstant (Fl (read x))
118c_strToFloat [VConstant (Str x)] = Just $ VConstant (Fl (read x))
112c_strToFloat _ = Nothing
119c_strToFloat _ = Nothing
121+p_floatExp [VConstant (Fl x)] = Just $ VConstant (Fl (exp x))
122+p_floatExp _ = Nothing
123+p_floatLog [VConstant (Fl x)] = Just $ VConstant (Fl (log x))
124+p_floatLog _ = Nothing
114elabPrim :: Prim -> Idris ()
126elabPrim :: Prim -> Idris ()
115elabPrim (Prim n ty i def epic)
127elabPrim (Prim n ty i def epic)
116 = do updateContext (addOperator n ty i def)
128 = do updateContext (addOperator n ty i def)