bmillwood / pointfree

Maintenance of the pointfree Hackage package.
MIT License
144 stars 22 forks source link

Should "flip id" be "(&)" instead? #25

Open stuartpb opened 7 years ago

stuartpb commented 7 years ago

Passing flip' x y = y x on pointfree.io returns flip' = flip id instead of just flip' = flip, which would be equivalent, and neater.

camilstaps commented 7 years ago

flip' x y = y x is not equivalent to flip f x y = f y x. Note that id x = x and id' x y = x y are equivalent, which explains that flip id' x y = id' y x = y x = flip' x y.

stuartpb commented 7 years ago

Right, I'd forgotten about the f that flip takes, and flip' f x y = f y x does indeed reduce to flip' = flip.

Is there no shorter name for reverse-function-application than flip id, then? I'd heard some rumbling about & on Reddit (I seem to remember finding some documentation saying its purpose was to allow nesting in $ clauses), but I can't find any documentation on it at the moment. (No results on Hoogle, and that's the problem with single-punctuation-character function names: they're impossible to Google.)

camilstaps commented 7 years ago

Yes, you could say that flip' = &, but that operator is only available in the newest GHC, so not sure if the maintainer wants to use it in pointfree already. You can find it on the beta version of hoogle: http://hoogle.haskell.org/?hoogle=%26&scope=set%3Astackage

bmillwood commented 1 year ago

I think it's fine to use & at this stage, but I don't think I'll get round to spending time on it personally :)