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

Mateusz Kowalczyk fuuzetsu at fuuzetsu.co.uk
Sat Aug 17 11:40:12 CEST 2013


On 17/08/13 10:11, Christopher Done wrote:
> Anyone ever needed this? Me and John Wiegley were discussing a decent
> name for it, John suggested inv as in involution. E.g.
First thing I thought was ‘inverse’…
> 
> 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.
> 
I do this a lot as well. Why not skip the ‘g’ all together and have ‘f .
reverse . f’ if that's all we're doing? You could even call it fromEnd
at that point and we end up with a rather intuitive ‘fromEnd (drop 10)’.
Maybe even just have an operator.
> 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.
> 


Is this a proposal for addition to something or is it just general
discussion?


-- 
Mateusz K.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0x2ADA9A97.asc
Type: application/pgp-keys
Size: 5619 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130817/f9aa5230/attachment.key>


More information about the Haskell-Cafe mailing list