I have a Haskell function like this:
in2out :: String -> String
in2out s =
show (sumAllLineValues $ lines s)
(where sumAllLineValues is defined in my code.)
How can I define in2out point-free, so without the parameter s?
I have a Haskell function like this:
in2out :: String -> String
in2out s =
show (sumAllLineValues $ lines s)
(where sumAllLineValues is defined in my code.)
How can I define in2out point-free, so without the parameter s?
Copyright © 2021 Jogjafile Inc.
To make a function pointfree, you need to rearrange the uses of all of its arguments such that they can be eta-reduced away. In this case, the argument is already used exactly once and all the way on the right, so all you need to do is get it out of the parentheses, which you can do by using function composition (
.):And then eta-reduce it away: