> The order [...] is quite different to english but very similar to functional programming.
The most widely accepted (imo) order of function composition is right to left:
send(makeUrl("http://..."))
just like in English "blue fish": transformation stands to the left to the object that is being transformed (*). Whereas "transformation follows the object" is an OO tradition, as shown in your examples. "Take object, apply transformation (method) yielding another object, apply transformation to that new object, etc."
(*) In quintessentially functional Haskell, you can compose functions both ways, but right-to-left is more traditional:
{-
- Find numeric value of the first figure of the decimal representation
- of a number:
- 1. convert it to a string of decimal characters (show)
- 2. take the first character of the string (head)
- 3. convert the character to a string containing one charcter (:[])
- 4. convert the string of one decimal character into an integer (read :: Int)
-}
main = do
let
firstfigure1 :: Int
firstfigure1 = read . (:[]) . head . show $ 413
print firstfigure1
{-
- Reverse the order of composition. Define "right-pointing" versions for
- (.) and ($)
-}
let
(.>) = flip (.) -- it will become infixl 9 by default
($>) = flip ($)
infixr 0 $> -- We need value lower than the above. Use the same as $
firstfigure2 :: Int
firstfigure2 = 413 $> show .> head .> (:[]) .> read :: Int
print firstfigure2
I take an issue though with this assertion:
> The order [...] is quite different to english but very similar to functional programming.
The most widely accepted (imo) order of function composition is right to left:
just like in English "blue fish": transformation stands to the left to the object that is being transformed (*). Whereas "transformation follows the object" is an OO tradition, as shown in your examples. "Take object, apply transformation (method) yielding another object, apply transformation to that new object, etc."(*) In quintessentially functional Haskell, you can compose functions both ways, but right-to-left is more traditional: