Hi,
as for the nomenclature - mathematically the pattern
f^{-1} . g . f
is sometimes called conjugation [1]. One (trivial) type of occurrence is
data Foo a = Foo { unFoo :: a }
deriving Show
instance Functor Foo where
fmap f = Foo . f . unFoo
The under function from the lens library [2]
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.
On 17 August 2013 19:11, Christopher Done chrisd...@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
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
In J (a sort of dialect of APL), there's a thing called under, written
.. The expression (f . g) x is equivalent to (g^:_1) (f (g x))
where g^:_1 is J's obverse of g, which in cases where it exists is
usually the inverse of g (
http://www.jsoftware.com/help/dictionary/intro26.htm). Abusing
On Sat, Aug 17, 2013 at 11:11:07AM +0200, 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.
inv reverse (take 10)
inv reverse (dropWhile isDigit)
trim = inv reverse (dropWhile isSpace) .
Note that at least for the dropWhile example, there is a specialized
function, dropWhileEnd, which is most likely more efficient than reversing
the list twice.
On Aug 17, 2013 3:35 PM, Tom Ellis
tom-lists-haskell-cafe-2...@jaguarpaw.co.uk wrote:
On Sat, Aug 17, 2013 at 11:11:07AM +0200,
Hi,
Am Samstag, den 17.08.2013, 11:11 +0200 schrieb Christopher Done:
inv reverse (take 10)
if you want that fast and lazy, check out
http://www.joachim-breitner.de/blog/archives/600-On-taking-the-last-n-elements-of-a-list.html
Greetings,
Joachim
--
Joachim “nomeata” Breitner
Christopher Done chrisd...@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
This is indeed a job for lens, particularly, the Iso type, and the under
function. Lens conveniently comes with a typeclassed isomorphism called
reversed, which of course has a list instance.
under reversed (take 10) ['a'.. 'z']
qrstuvwxyz
-- Dan Burton
On Aug 17, 2013 10:23 AM, Anton Nikishaev
The lens docs even have an example of another helper function, involuted
for functions which are their own inverse.
live involuted reverse %~ ('d':)
lived
inv f g = involuted f %~ g
http://hackage.haskell.org/packages/archive/lens/3.9.0.2/doc/html/Control-Lens-Iso.html#v:involuted
-- Dan
Dan Burton danburton.em...@gmail.com writes:
under reversed (take 10) ['a'.. 'z']
qrstuvwxyz
Excellent, thanks!
--
John Wiegley
FP Complete Haskell tools, training and consulting
http://fpcomplete.com johnw on #haskell/irc.freenode.net
12 matches
Mail list logo