
Eitan Goldshtrom wrote:
f p = putStrLn $ (show (Main.id p)) ++ " - message received"
Brandon S Allbery KF8NH wrote:
f p = putStrLn $ (show $ Main.id p) ++ " = message received"
wren ng thornton
f p = putStrLn $ show (Main.id p) ++ " - message received" f p = putStrLn $ (show . Main.id) p ++ " - message received" f p = putStrLn $ ((show . Main.id) p) ++ " - message received" f p = putStrLn $ (show . Main.id $ p) ++ " - message received" f p = putStrLn ((show . Main.id $ p) ++ " - message received") etc.
I think the clearest way to write it is: f = putStrLn . (++ " - message received") . show . Main.id Not because it happens to be point-free, but because it is the "combinator" approach. You apply functions one after the other, each with its own simple meaning and purpose. If I were to describe to someone in words what this function does, I would say something like: "Apply Main.id, turn it into a string, tack a message onto the end, and print it." So why not write it that way in Haskell? One of the nicest features of Haskell is that the combinator approach is often so natural. Regards, Yitz