[Haskell-cafe] inv f g = f . g . f

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Sat Aug 17 11:21:11 CEST 2013


On 17 August 2013 19:11, Christopher Done <chrisdone at gmail.com> wrote:
> Anyone ever needed this? Me and John Wiegley were discussing a decent
> name for it, John suggested inv as in involution. E.g.

In terms of a decent name: as soon as I saw the subject, I thought you
were somehow inverting a function :/

In terms of how useful it is, I don't think I tend to use such an idiom.

>
> inv reverse (take 10)
> inv reverse (dropWhile isDigit)
> trim = inv reverse (dropWhile isSpace) . dropWhile isSpace
>
> That seems to be the only use-case I've ever come across.
>
> There's also this one:
>
> co f g = f g . g
>
> which means you can write
>
> trim = co (inv reverse) (dropWhile isSpace)
>
> but that's optimizing an ever rarer use-case.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com




More information about the Haskell-Cafe mailing list