operations on lists
This commit is contained in:
@@ -118,6 +118,10 @@ corePrelude = Module (Just ("Prelude", [])) $
|
||||
twice f x = f (f x);
|
||||
fst p = casePair# p k;
|
||||
snd p = casePair# p k1;
|
||||
head l = caseList# l abort# k;
|
||||
tail l = caseList# l abort# k1;
|
||||
_length_cc x xs = (+#) 1 (length xs);
|
||||
length l = caseList# l 0 length_cc;
|
||||
|]
|
||||
<>
|
||||
-- primitive constructors need some specialised wiring:
|
||||
|
||||
@@ -49,6 +49,7 @@ data Prim = ConP Int Int -- ConP Tag Arity
|
||||
| IntEqP
|
||||
| CasePairP
|
||||
| CaseListP
|
||||
| AbortP
|
||||
deriving (Show, Eq)
|
||||
|
||||
instance Pretty Prim where
|
||||
@@ -105,6 +106,7 @@ primitives =
|
||||
, ("if#", IfP)
|
||||
, ("casePair#", CasePairP)
|
||||
, ("caseList#", CaseListP)
|
||||
, ("abort#", AbortP)
|
||||
]
|
||||
|
||||
instantiate :: Expr -> TiHeap -> [(Name, Addr)] -> (TiHeap, Addr)
|
||||
@@ -335,6 +337,9 @@ step st =
|
||||
rootAddr = s !! a
|
||||
argAddrs = getArgs h s
|
||||
|
||||
primStep _ AbortP (TiState s d h g sts) =
|
||||
error "rl' called abort#!"
|
||||
|
||||
dataStep :: Int -> [Addr] -> TiState -> TiState
|
||||
dataStep _ _ (TiState [a] (s:d) h g sts) = TiState s d h g sts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user