1 module PreludeFoldrBuild where
5 -----------------------------------------------------------------
6 -- This needs to be in a sperate module, other than in List.hs
7 -- NOTE: no foldr/build's are done on the module that foldr is defined in.
9 {-# MAGIC_UNFOLDING foldr foldr #-}
10 {-# GENERATE_SPECS foldr a b #-}
11 foldr :: (a -> b -> b) -> b -> [a] -> b
13 foldr f z (x:xs) = f x (foldr f z xs)
15 {-# MAGIC_UNFOLDING foldl foldl #-}
16 {-# GENERATE_SPECS foldl a b #-}
17 foldl :: (a -> b -> a) -> a -> [b] -> a
19 foldl f z (x:xs) = foldl f (f z x) xs
22 -- HACK: Magic unfoldings not implemented for unboxed lists
23 -- Need to define a _build to avoid undefined symbol
25 {-# GENERATE_SPECS _build a #-}
26 _build :: ((a -> [a] -> [a]) -> [a] -> [a]) -> [a]