[Haskell-cafe] inv f g = f . g . f
Anton Nikishaev
me at lelf.lu
Sat Aug 17 19:20:04 CEST 2013
Christopher Done <chrisdone at gmail.com> writes:
> Anyone ever needed this? Me and John Wiegley were discussing a decent
> name for it, John suggested inv as in involution. E.g.
>
> 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.
And it's here only because reverse^-1 ≡ reverse, is not it?
I only can see how f ∘ g ∘ f^-1 can be a pattern.
> 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.
--
lelf
More information about the Haskell-Cafe
mailing list