diff --git a/src/Core/Examples.hs b/src/Core/Examples.hs index 209c15e..a7a7c0a 100644 --- a/src/Core/Examples.hs +++ b/src/Core/Examples.hs @@ -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: diff --git a/src/TIM.hs b/src/TIM.hs index 47a92b5..87bb36b 100644 --- a/src/TIM.hs +++ b/src/TIM.hs @@ -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