====== Composition operator ======
* composition operator is "."
* type: ''(b -> c) -> (a -> b) -> a -> c''
* takes two functions as parameter and combines the functions
* first function is applied to the result of the second function
* example:
import qualified Data.Char as Ch (ord)
main :: IO ()
main =
do
print $ f3 'a'
print $ f4 'a'
f1 :: Char -> Integer
f1 ch = toInteger $ Ch.ord(ch)
f2 :: Integer -> Double
f2 n = fromIntegral n :: Double
f3 :: Char -> Double
f3 = f2 . f1
f4 :: Char -> Double
f4 ch = f2 (f1 ch)
* executes with output:
97.0
97.0
===== ✎ =====
~~DISCUSSION~~