@@ -6,7 +6,7 @@ import Idris.ElabDecls
66import Idris.ElabTerm
77import Idris.AbsSyntax
88
9−import RTS.SC
9+import IRTS.Lang
1010
1111import Core.TT
1212import Core.Evaluate
@@ -19,7 +19,7 @@ data Prim = Prim { p_name :: Name,
1919 p_arity :: Int,
2020 p_def :: [Value] -> Maybe Value,
2121 p_epic :: ([E.Name], E.Term),
22− p_sc :: ([CType], CType, SPrim),
22+ p_lexp :: (Int, PrimFn),
2323 p_total :: Totality
2424 }
2525
@@ -82,146 +82,146 @@ partial = Partial NotCovering
8282primitives =
8383 -- operators
8484 [Prim (UN "prim__addInt") (ty [IType, IType] IType) 2 (iBin (+))
85− (eOp E.plus_) ([sInt, sInt], sInt, AddI) total,
85+ (eOp E.plus_) (2, LPlus) total,
8686 Prim (UN "prim__subInt") (ty [IType, IType] IType) 2 (iBin (-))
8787 (eOp E.minus_)
88− ([sInt, sInt], sInt, SubI) total,
88+ (2, LMinus) total,
8989 Prim (UN "prim__mulInt") (ty [IType, IType] IType) 2 (iBin (*))
90− (eOp E.times_) ([sInt, sInt], sInt, MulI) total,
90+ (eOp E.times_) (2, LTimes) total,
9191 Prim (UN "prim__divInt") (ty [IType, IType] IType) 2 (iBin (div))
92− (eOp E.divide_) ([sInt, sInt], sInt, DivI) partial,
92+ (eOp E.divide_) (2, LDiv) partial,
9393 Prim (UN "prim__eqInt") (ty [IType, IType] IType) 2 (biBin (==))
94− (eOp E.eq_) ([sInt, sInt], sInt, EqI) total,
94+ (eOp E.eq_) (2, LEq) total,
9595 Prim (UN "prim__ltInt") (ty [IType, IType] IType) 2 (biBin (<))
96− (eOp E.lt_) ([sInt, sInt], sInt, LtI) total,
96+ (eOp E.lt_) (2, LLt) total,
9797 Prim (UN "prim__lteInt") (ty [IType, IType] IType) 2 (biBin (<=))
98− (eOp E.lte_) ([sInt, sInt], sInt, LteI) total,
98+ (eOp E.lte_) (2, LLe) total,
9999 Prim (UN "prim__gtInt") (ty [IType, IType] IType) 2 (biBin (>))
100− (eOp E.gt_) ([sInt, sInt], sInt, GtI) total,
100+ (eOp E.gt_) (2, LGt) total,
101101 Prim (UN "prim__gteInt") (ty [IType, IType] IType) 2 (biBin (>=))
102− (eOp E.gte_) ([sInt, sInt], sInt, GteI) total,
102+ (eOp E.gte_) (2, LGe) total,
103103 Prim (UN "prim__eqChar") (ty [ChType, ChType] IType) 2 (bcBin (==))
104− (eOp E.eq_) ([sChar, sChar], sInt, EqC) total,
104+ (eOp E.eq_) (2, LEq) total,
105105 Prim (UN "prim__ltChar") (ty [ChType, ChType] IType) 2 (bcBin (<))
106− (eOp E.lt_) ([sChar, sChar], sInt, LtC) total,
106+ (eOp E.lt_) (2, LLt) total,
107107 Prim (UN "prim__lteChar") (ty [ChType, ChType] IType) 2 (bcBin (<=))
108− (eOp E.lte_) ([sChar, sChar], sInt, LteC) total,
108+ (eOp E.lte_) (2, LLe) total,
109109 Prim (UN "prim__gtChar") (ty [ChType, ChType] IType) 2 (bcBin (>))
110− (eOp E.gt_) ([sChar, sChar], sInt, GtC) total,
110+ (eOp E.gt_) (2, LGt) total,
111111 Prim (UN "prim__gteChar") (ty [ChType, ChType] IType) 2 (bcBin (>=))
112− (eOp E.gte_) ([sChar, sChar], sInt, GteC) total,
112+ (eOp E.gte_) (2, LGe) total,
113113 Prim (UN "prim__addBigInt") (ty [BIType, BIType] BIType) 2 (bBin (+))
114114 (eOpFn tyBigInt tyBigInt "addBig")
115− ([sBigInt, sBigInt], sBigInt, AddBI) total,
115+ (2, LBPlus) total,
116116 Prim (UN "prim__subBigInt") (ty [BIType, BIType] BIType) 2 (bBin (-))
117− (eOpFn tyBigInt tyBigInt "subBig") ([sBigInt, sBigInt], sBigInt, SubBI) total,
117+ (eOpFn tyBigInt tyBigInt "subBig") (2, LBMinus) total,
118118 Prim (UN "prim__mulBigInt") (ty [BIType, BIType] BIType) 2 (bBin (*))
119− (eOpFn tyBigInt tyBigInt "mulBig") ([sBigInt, sBigInt], sBigInt, MulBI) total,
119+ (eOpFn tyBigInt tyBigInt "mulBig") (2, LBTimes) total,
120120 Prim (UN "prim__divBigInt") (ty [BIType, BIType] BIType) 2 (bBin (div))
121− (eOpFn tyBigInt tyBigInt "divBig") ([sBigInt, sBigInt], sBigInt,DivBI) partial,
121+ (eOpFn tyBigInt tyBigInt "divBig") (2, LBDiv) partial,
122122 Prim (UN "prim__eqBigInt") (ty [BIType, BIType] IType) 2 (bbBin (==))
123− (eOpFn tyBigInt tyInt "eqBig") ([sBigInt, sBigInt], sInt, EqBI) total,
123+ (eOpFn tyBigInt tyInt "eqBig") (2, LBEq) total,
124124 Prim (UN "prim__ltBigInt") (ty [BIType, BIType] IType) 2 (bbBin (<))
125− (eOpFn tyBigInt tyInt "ltBig") ([sBigInt, sBigInt], sInt, LtBI) total,
125+ (eOpFn tyBigInt tyInt "ltBig") (2, LBLt) total,
126126 Prim (UN "prim__lteBigInt") (ty [BIType, BIType] IType) 2 (bbBin (<=))
127− (eOpFn tyBigInt tyInt "leBig") ([sBigInt, sBigInt], sInt, LteBI) total,
127+ (eOpFn tyBigInt tyInt "leBig") (2, LBLe) total,
128128 Prim (UN "prim__gtBigInt") (ty [BIType, BIType] IType) 2 (bbBin (>))
129− (eOpFn tyBigInt tyInt "gtBig") ([sBigInt, sBigInt], sInt, GtBI) total,
129+ (eOpFn tyBigInt tyInt "gtBig") (2, LBGt) total,
130130 Prim (UN "prim__gtBigInt") (ty [BIType, BIType] IType) 2 (bbBin (>=))
131− (eOpFn tyBigInt tyInt "geBig") ([sBigInt, sBigInt], sInt, GteBI) total,
131+ (eOpFn tyBigInt tyInt "geBig") (2, LBGe) total,
132132 Prim (UN "prim__addFloat") (ty [FlType, FlType] FlType) 2 (fBin (+))
133− (eOp E.plusF_) ([sFloat, sFloat], sFloat, AddF) total,
133+ (eOp E.plusF_) (2, LFPlus) total,
134134 Prim (UN "prim__subFloat") (ty [FlType, FlType] FlType) 2 (fBin (-))
135− (eOp E.minusF_) ([sFloat, sFloat], sFloat, SubF) total,
135+ (eOp E.minusF_) (2, LFMinus) total,
136136 Prim (UN "prim__mulFloat") (ty [FlType, FlType] FlType) 2 (fBin (*))
137− (eOp E.timesF_) ([sFloat, sFloat], sFloat, MulF) total,
137+ (eOp E.timesF_) (2, LFTimes) total,
138138 Prim (UN "prim__divFloat") (ty [FlType, FlType] FlType) 2 (fBin (/))
139− (eOp E.divideF_) ([sFloat, sFloat], sFloat, DivF) total,
139+ (eOp E.divideF_) (2, LFDiv) total,
140140 Prim (UN "prim__eqFloat") (ty [FlType, FlType] IType) 2 (bfBin (==))
141− (eOp E.eqF_) ([sFloat, sFloat], sInt, EqF) total,
141+ (eOp E.eqF_) (2, LFEq) total,
142142 Prim (UN "prim__ltFloat") (ty [FlType, FlType] IType) 2 (bfBin (<))
143− (eOp E.ltF_) ([sFloat, sFloat], sInt, LtF) total,
143+ (eOp E.ltF_) (2, LFLt) total,
144144 Prim (UN "prim__lteFloat") (ty [FlType, FlType] IType) 2 (bfBin (<=))
145− (eOp E.lteF_) ([sFloat, sFloat], sInt, LteF) total,
145+ (eOp E.lteF_) (2, LFLe) total,
146146 Prim (UN "prim__gtFloat") (ty [FlType, FlType] IType) 2 (bfBin (>))
147− (eOp E.gtF_) ([sFloat, sFloat], sInt, GtF) total,
147+ (eOp E.gtF_) (2, LFGt) total,
148148 Prim (UN "prim__gteFloat") (ty [FlType, FlType] IType) 2 (bfBin (>=))
149− (eOp E.gteF_) ([sFloat, sFloat], sInt, GteF) total,
149+ (eOp E.gteF_) (2, LFGe) total,
150150 Prim (UN "prim__concat") (ty [StrType, StrType] StrType) 2 (sBin (++))
151151 ([E.name "x", E.name "y"], (fun "append") @@ fun "x" @@ fun "y")
152− ([sString, sString], sString, ConcatS) total,
152+ (2, LStrConcat) total,
153153 Prim (UN "prim__eqString") (ty [StrType, StrType] IType) 2 (bsBin (==))
154154 ([E.name "x", E.name "y"], strEq (fun "x") (fun "y"))
155− ([sString, sString], sInt, EqS) total,
155+ (2, LStrEq) total,
156156 Prim (UN "prim__ltString") (ty [StrType, StrType] IType) 2 (bsBin (<))
157157 ([E.name "x", E.name "y"], strLt (fun "x") (fun "y"))
158− ([sString, sString], sInt, LtS) total,
158+ (2, LStrLt) total,
159159 -- Conversions
160160 Prim (UN "prim__strToInt") (ty [StrType] IType) 1 (c_strToInt)
161− ([E.name "x"], strToInt (fun "x")) ([sString], sInt, StoI) total,
161+ ([E.name "x"], strToInt (fun "x")) (1, LStrInt) total,
162162 Prim (UN "prim__intToStr") (ty [IType] StrType) 1 (c_intToStr)
163− ([E.name "x"], intToStr (fun "x")) ([sInt], sString, ItoS) total,
163+ ([E.name "x"], intToStr (fun "x")) (1, LIntStr) total,
164164 Prim (UN "prim__charToInt") (ty [ChType] IType) 1 (c_charToInt)
165− ([E.name "x"], charToInt (fun "x")) ([sChar], sInt, CtoI) total,
165+ ([E.name "x"], charToInt (fun "x")) (1, LNoOp) total,
166166 Prim (UN "prim__intToChar") (ty [IType] ChType) 1 (c_intToChar)
167− ([E.name "x"], intToChar (fun "x")) ([sInt], sChar, ItoC) total,
167+ ([E.name "x"], intToChar (fun "x")) (1, LNoOp) total,
168168 Prim (UN "prim__intToBigInt") (ty [IType] BIType) 1 (c_intToBigInt)
169− ([E.name "x"], intToBigInt (fun "x")) ([sInt], sBigInt, ItoBI) total,
169+ ([E.name "x"], intToBigInt (fun "x")) (1, LIntBig) total,
170170 Prim (UN "prim__bigIntToInt") (ty [BIType] IType) 1 (c_bigIntToInt)
171− ([E.name "x"], bigIntToInt (fun "x")) ([sBigInt], sInt, BItoI) total,
171+ ([E.name "x"], bigIntToInt (fun "x")) (1, LBigInt) total,
172172 Prim (UN "prim__strToBigInt") (ty [StrType] BIType) 1 (c_strToBigInt)
173− ([E.name "x"], strToBigInt (fun "x")) ([sString], sBigInt, StoBI) total,
173+ ([E.name "x"], strToBigInt (fun "x")) (1, LStrBig) total,
174174 Prim (UN "prim__bigIntToStr") (ty [BIType] StrType) 1 (c_bigIntToStr)
175− ([E.name "x"], bigIntToStr (fun "x")) ([sBigInt], sString, BItoS) total,
175+ ([E.name "x"], bigIntToStr (fun "x")) (1, LBigStr) total,
176176 Prim (UN "prim__strToFloat") (ty [StrType] FlType) 1 (c_strToFloat)
177− ([E.name "x"], strToFloat (fun "x")) ([sString], sFloat, StoF) total,
177+ ([E.name "x"], strToFloat (fun "x")) (1, LStrFloat) total,
178178 Prim (UN "prim__floatToStr") (ty [FlType] StrType) 1 (c_floatToStr)
179− ([E.name "x"], floatToStr (fun "x")) ([sFloat], sString, FtoS) total,
179+ ([E.name "x"], floatToStr (fun "x")) (1, LFloatStr) total,
180180 Prim (UN "prim__intToFloat") (ty [IType] FlType) 1 (c_intToFloat)
181− ([E.name "x"], intToFloat (fun "x")) ([sInt], sFloat, ItoF) total,
181+ ([E.name "x"], intToFloat (fun "x")) (1, LIntFloat) total,
182182 Prim (UN "prim__floatToInt") (ty [FlType] IType) 1 (c_floatToInt)
183− ([E.name "x"], floatToInt (fun "x")) ([sFloat], sInt, FtoI) total,
183+ ([E.name "x"], floatToInt (fun "x")) (1, LFloatInt) total,
184184
185185 Prim (UN "prim__floatExp") (ty [FlType] FlType) 1 (p_floatExp)
186− ([E.name "x"], floatExp (fun "x")) ([sFloat], sFloat, ExpF) total,
186+ ([E.name "x"], floatExp (fun "x")) (1, LFExp) total,
187187 Prim (UN "prim__floatLog") (ty [FlType] FlType) 1 (p_floatLog)
188− ([E.name "x"], floatLog (fun "x")) ([sFloat], sFloat, LogF) total,
188+ ([E.name "x"], floatLog (fun "x")) (1, LFLog) total,
189189 Prim (UN "prim__floatSin") (ty [FlType] FlType) 1 (p_floatSin)
190− ([E.name "x"], floatSin (fun "x")) ([sFloat], sFloat, SinF) total,
190+ ([E.name "x"], floatSin (fun "x")) (1, LFSin) total,
191191 Prim (UN "prim__floatCos") (ty [FlType] FlType) 1 (p_floatCos)
192− ([E.name "x"], floatCos (fun "x")) ([sFloat], sFloat, CosF) total,
192+ ([E.name "x"], floatCos (fun "x")) (1, LFCos) total,
193193 Prim (UN "prim__floatTan") (ty [FlType] FlType) 1 (p_floatTan)
194− ([E.name "x"], floatTan (fun "x")) ([sFloat], sFloat, TanF) total,
194+ ([E.name "x"], floatTan (fun "x")) (1, LFTan) total,
195195 Prim (UN "prim__floatASin") (ty [FlType] FlType) 1 (p_floatASin)
196− ([E.name "x"], floatASin (fun "x")) ([sFloat], sFloat, ASinF) total,
196+ ([E.name "x"], floatASin (fun "x")) (1, LFASin) total,
197197 Prim (UN "prim__floatACos") (ty [FlType] FlType) 1 (p_floatACos)
198− ([E.name "x"], floatACos (fun "x")) ([sFloat], sFloat, ACosF) total,
198+ ([E.name "x"], floatACos (fun "x")) (1, LFACos) total,
199199 Prim (UN "prim__floatATan") (ty [FlType] FlType) 1 (p_floatATan)
200− ([E.name "x"], floatATan (fun "x")) ([sFloat], sFloat, ATanF) total,
200+ ([E.name "x"], floatATan (fun "x")) (1, LFATan) total,
201201 Prim (UN "prim__floatSqrt") (ty [FlType] FlType) 1 (p_floatSqrt)
202− ([E.name "x"], floatSqrt (fun "x")) ([sFloat], sFloat, SqrtF) total,
202+ ([E.name "x"], floatSqrt (fun "x")) (1, LFSqrt) total,
203203 Prim (UN "prim__floatFloor") (ty [FlType] FlType) 1 (p_floatFloor)
204− ([E.name "x"], floatFloor (fun "x")) ([sFloat], sFloat, FloorF) total,
204+ ([E.name "x"], floatFloor (fun "x")) (1, LFFloor) total,
205205 Prim (UN "prim__floatCeil") (ty [FlType] FlType) 1 (p_floatCeil)
206− ([E.name "x"], floatCeil (fun "x")) ([sFloat], sFloat, CeilF) total,
206+ ([E.name "x"], floatCeil (fun "x")) (1, LFCeil) total,
207207
208208 Prim (UN "prim__strHead") (ty [StrType] ChType) 1 (p_strHead)
209− ([E.name "x"], strHead (fun "x")) ([sString], sChar, HeadS) partial,
209+ ([E.name "x"], strHead (fun "x")) (1, LStrHead) partial,
210210 Prim (UN "prim__strTail") (ty [StrType] StrType) 1 (p_strTail)
211− ([E.name "x"], strTail (fun "x")) ([sString], sString, TailS) partial,
211+ ([E.name "x"], strTail (fun "x")) (1, LStrTail) partial,
212212 Prim (UN "prim__strCons") (ty [ChType, StrType] StrType) 2 (p_strCons)
213213 ([E.name "x", E.name "xs"], strCons (fun "x") (fun "xs"))
214− ([sChar, sString], sString, ConsS) total,
214+ (2, LStrCons) total,
215215 Prim (UN "prim__strIndex") (ty [StrType, IType] ChType) 2 (p_strIndex)
216216 ([E.name "x", E.name "i"], strIndex (fun "x") (fun "i"))
217− ([sString, sInt], sChar, IndexS) partial,
217+ (2, LStrIndex) partial,
218218 Prim (UN "prim__strRev") (ty [StrType] StrType) 1 (p_strRev)
219219 ([E.name "x"], strRev (fun "x"))
220− ([sString], sString, RevS) total,
220+ (1, LStrRev) total,
221221
222222 Prim (UN "prim__believe_me") believeTy 3 (p_believeMe)
223223 ([E.name "a", E.name "b", E.name "x"], fun "x")
224− ([Nothing], Nothing, BelieveMe) total -- ahem
224+ (1, LNoOp) total -- ahem
225225 ]
226226
227227p_believeMe [_,_,x] = Just x