Sometimes you want the function which takes two arguments and ignores the first. You can write that as:
flip const
\_ x -> x
const id
\_ -> id
Assuming that thing is called f, and we pass around a WHNF f x, the first two of those will leave the x captured. But in my view, the first two are also clearer to read. I however, don't guarantee that's true, my reasoning may be wrong....
It seems like having a flipConst or other function might be useful, with the best space behaviour it can do? Or maybe the restriction to only after people seq a function is just not helpful? Is there a good name for this function? Do lambdas really reduce differently for \x y -> ... vs \x -> \y -> ...? Or does the id make it different?
CC @josephcsible who brought this up first in HLint.
Sometimes you want the function which takes two arguments and ignores the first. You can write that as:
Assuming that thing is called
f, and we pass around a WHNFf x, the first two of those will leave thexcaptured. But in my view, the first two are also clearer to read. I however, don't guarantee that's true, my reasoning may be wrong....It seems like having a
flipConstor other function might be useful, with the best space behaviour it can do? Or maybe the restriction to only after people seq a function is just not helpful? Is there a good name for this function? Do lambdas really reduce differently for\x y -> ...vs\x -> \y -> ...? Or does theidmake it different?CC @josephcsible who brought this up first in HLint.