blob: 6201af48577054bf220b1d5136fe909265e6f0f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
module PreludeFoldrBuild where
import Builtin (error)
-----------------------------------------------------------------
-- This needs to be in a sperate module, other than in List.hs
-- NOTE: no foldr/build's are done on the module that foldr is defined in.
{-# MAGIC_UNFOLDING foldr foldr #-}
foldr :: (a -> b -> b) -> b -> [a] -> b
foldr f z [] = z
foldr f z (x:xs) = f x (foldr f z xs)
{-# MAGIC_UNFOLDING foldl foldl #-}
--{-# GENERATE_SPECS foldl a b #-}
foldl :: (a -> b -> a) -> a -> [b] -> a
foldl f z [] = z
foldl f z (x:xs) = foldl f (f z x) xs
|