[Haskell-cafe] Pointfree composition for higher arity

Sean Leather leather at cs.uu.nl
Wed Feb 17 16:23:29 EST 2010


On Wed, Feb 17, 2010 at 16:48, Stephen Tetley wrote:

> On 17 February 2010 15:41, Mike Dillon <mike at embody.org> wrote:
> > That signature is the `oo` "specs" combinator in Data.Aviary:
>

Nice!

 I wouldn't recommend writing code that depends on Data.Aviary, but
> some of the combinators are often worth copy/pasting out of it.
>

On the contrary, I think the specs combinators and perhaps others in
Data.Aviary (probably not Data.Aviary.*) have potential. We could even
generalize oo and the others to categories and add it to Control.Category
(which is, after all, looking rather empty).

import Control.Category
> import Prelude hiding ((.))
>
> -- oo :: (c -> d) -> (a -> b -> c) -> a -> b -> d
> oo :: (Category cat) => cat c d -> (a -> cat b c) -> a -> cat b d
> oo = (.) . (.)
>
> -- ooo :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e
> ooo :: (Category cat) => cat d e -> (a -> b -> cat c d) -> a -> b -> cat c
> e
> ooo = (.) . (.) . (.)
>
> -- oooo :: (e -> f) -> (a -> b -> c -> d -> e) -> a -> b -> c -> d -> f
> oooo :: (Category cat) => cat e f -> (a -> b -> c -> cat d e) -> a -> b ->
> c -> cat d f
> oooo = (.) . (.) . (.) . (.)
>

Is it necessary? Maybe not.

I'm guessing that the names oo, etc. do not have a commonly accepted
meaning, so I like them. I'd like to have a module (e.g. Control.Pointfree)
containing these and other useful general combinators from the community.

Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/6b625662/attachment-0001.html


More information about the Haskell-Cafe mailing list