is point free code more efficient, or just terser?

Viewed 1309

I wrote the following code, which takes a bunch of points and draws them on the screen using the gloss library.

let s = blocks pes
    pts = map (map mkPt) s  {- stitches to points-}
    lines = map Line pts    {-points to lines -}
    pict = Pictures lines   {- lines to a picture -}
  in do  displayInWindow "My Window" (200, 200) (10, 10) white pict

It works fine, but it occurs to me that there's a repeated pattern: a chain of function calls, the result of each one feeding into the last argument of the next. So I refactored by removing the intermediate variables, reversing the order and chaining the functions with function composition (".") like so:

let pict = Pictures . (map Line) . (map $ map $ mkPt) . blocks $ pes
                in do  displayInWindow "My Window" (200, 200) (10, 10) white pict

Happily, this works just fine too. But I'm wondering if I'm straining readability, or if I'm just not used to reading & writing point free style code. Also, how do I reason about this code? Is the second version more efficient, or just terser? Is there anything I can do stylistically to make it clearer?

2 Answers
Related