Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

28 lines (20 sloc) 0.553 kb
We have developed a method for short-cut fusion using |foldr|/|build|. By introducing the definition:
\begin{code}
build :: ((a -> [a] -> [a]) -> [b] -> c) -> c
build g = g (:) []
\end{code}
The standard definition of |map| is:
\begin{code}
map :: (a -> b) -> [a] -> [b]
map f [] = []
map f (x:xs) = f x : map f xs
\end{code}
But we redefine it as:
\begin{code}
map :: (a -> b) -> [a] -> [b]
map f = foldr ((:) . f) []
\end{code}
Which now allows us to have the property:
\begin{code}
propEq g k z = foldr k z (build g) == g k z
\end{code}
Jump to Line
Something went wrong with that request. Please try again.