[Haskell-cafe] (a -> [b]) -> [a -> b] ?

David Roundy droundy at darcs.net
Mon Dec 4 14:37:00 EST 2006

On Mon, Dec 04, 2006 at 07:00:23PM +0000, Joachim Breitner wrote:
> I came up with:
> 	\g -> map (\n a -> g a !! n) [1..]
> which has the desired type and functionality, but it looks rather
> inelegant and messy. Any better ideas?

I like

sequence a2bs = (head . a2bs) : sequence (tail . a2bs)

This also makes it explicit that by golly your function had better return
an infinite list, or we're in trouble.
David Roundy
Department of Physics
Oregon State University

More information about the Haskell-Cafe mailing list