[Haskell-cafe] A handy little consequence of the Cont monad
Derek Elkins
derek.a.elkins at gmail.com
Fri Feb 1 16:27:06 EST 2008
On Fri, 2008-02-01 at 00:09 -0500, Cale Gibbard wrote:
> Hello,
>
> Today on #haskell, resiak was asking about a clean way to write the
> function which allocates an array of CStrings using withCString and
> withArray0 to produce a new with* style function. I came up with the
> following:
>
> nest :: [(r -> a) -> a] -> ([r] -> a) -> a
> nest xs = runCont (sequence (map Cont xs))
This is what you write after all that time on #haskell?
nest = runCont . sequence . map Cont
More information about the Haskell-Cafe
mailing list