<div dir="ltr"><font face="monospace, monospace">I recently realized one important reason Haskell is so compact---it provides structures that avoid the need to name intermediate variables. I guess it's obvious, but coming from an imperative background I didn't see this at first. I am starting to recognize situations where all the existing wonderful typeclasses assist in eliminating variables.</font><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Function composition is the simplest example. I sometimes write long chains of composed functions. In an imperative language with a less compact function call syntax, that would require so many parentheses that you would probably break it over several statements, then forcing you to use more variables.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Then I realized that Arrows allow a little more flexibility when you have different numbers of arguments to feed, say when you split a single argument into two, or want to construct a function that applies to one argument and ignores the other.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">...So I had to write something like this.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">compute :: [Int] -> [Int] -> [Int] -> [(Int,Int)]</font></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">func :: [Int] -> [(Int,Int)]</span><br></div><div><font face="monospace, monospace">func xs = compute xs (filter isSmall xs) (filter isLarge xs)</font></div><div><br></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">but I could also write</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">compute :: ([Int],([Int],[Int])) -> [(Int,Int)]</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">func = compute . (id &&& filter isSmall &&& filter isLarge)</font></div><div><br></div><div><font face="monospace, monospace">So I had to change the inputs to 'compute' into this kind of awkward tuple form, but I eliminated four 'xs', plus eliminated the need to come up with the name 'xs'. </font></div><div><br></div><div><font face="monospace, monospace">Can I get a comment on whether this makes sense as way to do things?</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">D</font></div><div><font face="monospace, monospace"><br></font></div><div><br></div></div>