on master help sign in
Added prim__bigIntToInt (needs latest EpiVM)
c666be8Edwin Brady
idris.cabal+1−1
@@ -67,7 +67,7 @@ Executable idris
67
67
68 Build-depends: base>=4 && <5, parsec, mtl, Cabal, haskeline,
68 Build-depends: base>=4 && <5, parsec, mtl, Cabal, haskeline,
69 containers, process, transformers, filepath, directory,
69 containers, process, transformers, filepath, directory,
70− binary, bytestring, epic>=0.9.2
70+ binary, bytestring, epic>=0.9.2.1
71
71
72 Extensions: MultiParamTypeClasses, FunctionalDependencies,
72 Extensions: MultiParamTypeClasses, FunctionalDependencies,
73 FlexibleInstances, TemplateHaskell
73 FlexibleInstances, TemplateHaskell
src/Idris/Primitives.hs+5
@@ -45,6 +45,7 @@ intToStr x = foreign_ tyString "intToStr" [(x, tyInt)]
45charToInt x = x
45charToInt x = x
46intToChar x = x
46intToChar x = x
47intToBigInt x = foreign_ tyBigInt "intToBigInt" [(x, tyInt)]
47intToBigInt x = foreign_ tyBigInt "intToBigInt" [(x, tyInt)]
48+bigIntToInt x = foreign_ tyInt "bigIntToInt" [(x, tyBigInt)]
48strToBigInt x = foreign_ tyBigInt "strToBig" [(x, tyString)]
49strToBigInt x = foreign_ tyBigInt "strToBig" [(x, tyString)]
49bigIntToStr x = foreign_ tyString "bigToStr" [(x, tyBigInt)]
50bigIntToStr x = foreign_ tyString "bigToStr" [(x, tyBigInt)]
50strToFloat x = foreign_ tyFloat "strToFloat" [(x, tyString)]
51strToFloat x = foreign_ tyFloat "strToFloat" [(x, tyString)]
@@ -158,6 +159,8 @@ primitives =
158 ([E.name "x"], intToChar (fun "x")) total,
159 ([E.name "x"], intToChar (fun "x")) total,
159 Prim (UN "prim__intToBigInt") (ty [IType] BIType) 1 (c_intToBigInt)
160 Prim (UN "prim__intToBigInt") (ty [IType] BIType) 1 (c_intToBigInt)
160 ([E.name "x"], intToBigInt (fun "x")) total,
161 ([E.name "x"], intToBigInt (fun "x")) total,
162+ Prim (UN "prim__bigIntToInt") (ty [BIType] IType) 1 (c_bigIntToInt)
163+ ([E.name "x"], bigIntToInt (fun "x")) total,
161 Prim (UN "prim__strToBigInt") (ty [StrType] BIType) 1 (c_strToBigInt)
164 Prim (UN "prim__strToBigInt") (ty [StrType] BIType) 1 (c_strToBigInt)
162 ([E.name "x"], strToBigInt (fun "x")) total,
165 ([E.name "x"], strToBigInt (fun "x")) total,
163 Prim (UN "prim__bigIntToStr") (ty [BIType] StrType) 1 (c_bigIntToStr)
166 Prim (UN "prim__bigIntToStr") (ty [BIType] StrType) 1 (c_bigIntToStr)
@@ -257,6 +260,8 @@ c_charToInt _ = Nothing
257
260
258c_intToBigInt [VConstant (I x)] = Just $ VConstant (BI (fromIntegral x))
261c_intToBigInt [VConstant (I x)] = Just $ VConstant (BI (fromIntegral x))
259c_intToBigInt _ = Nothing
262c_intToBigInt _ = Nothing
263+c_bigIntToInt [VConstant (BI x)] = Just $ VConstant (I (fromInteger x))
264+c_bigIntToInt _ = Nothing
260
265
261c_bigIntToStr [VConstant (BI x)] = Just $ VConstant (Str (show x))
266c_bigIntToStr [VConstant (BI x)] = Just $ VConstant (Str (show x))
262c_bigIntToStr _ = Nothing
267c_bigIntToStr _ = Nothing