[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / lib / prelude / FoldrBuild.hs
1 module PreludeFoldrBuild where
2
3 import Builtin (error)
4
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.
8
9 {-# MAGIC_UNFOLDING foldr foldr #-}
10 foldr                   :: (a -> b -> b) -> b -> [a] -> b
11 foldr f z []            =  z
12 foldr f z (x:xs)        =  f x (foldr f z xs)
13
14 {-# MAGIC_UNFOLDING foldl foldl #-}
15 --{-# GENERATE_SPECS foldl a b #-}
16 foldl                   :: (a -> b -> a) -> a -> [b] -> a
17 foldl f z []            =  z
18 foldl f z (x:xs)        =  foldl f (f z x) xs
19
20