-- add.hs  Add two numbers (ignore the rest)

module Main where

{-
   (.)      :: (a->b) -> (c->a) -> c -> b ;  function composition
   (++)     :: String->String->String   ; append strings togther
   words    :: String->[String]         ; breaks a string into words at whitespace
   interact :: (String->String) -> IO (); the input and output are strings
   map      :: a->b -> [a] ->[b]        ; apply function to every item in sequence
 -}

main = interact (fmt . add2 . map read . words)

add2 :: [Int] -> Int
add2 (a:b:rest) = (a+b)

fmt :: Int -> String
fmt x =  "The result is " ++ (show x) ++ "\n"

--  ------------For GNU Emacs ------------
--  Local Variables:
--  compile-command: "ghc -Wall add.hs"
--  End: