[Haskell-cafe] A handy little consequence of the Cont monad

Lennart Augustsson lennart at augustsson.net
Fri Feb 1 17:19:17 EST 2008


It's a matter of taste.  I prefer the function composition in this case.
It reads nicely as a pipeline.

  -- Lennart

On Fri, Feb 1, 2008 at 9:48 PM, Dan Licata <drl at cs.cmu.edu> wrote:

> Not to start a flame war or religious debate, but I don't think that
> eta-expansions should be considered bad style.  I realize that
> composition-style is good for certain types of reasoning, but fully
> eta-expanded code has an important legibility advantage: you can tell
> the shape of its type just by looking at it!  Personally, I'd rather
> read the original version.
>
> -Dan
>
> On Feb01, Derek Elkins wrote:
> > 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
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080201/21ca5539/attachment.htm


More information about the Haskell-Cafe mailing list