

-- a comment
-- 

-- a simple function
f :: (Num a) => a -> a -> a
f x y = x + y


-- a function that maps to a tuple
g :: Int -> (Int,  Int)
g x = (x, x + 1)

-- Example of the IO Monad.
main = do
     print "Hello World"


myReverse :: String -> String
          -- [Char] -> [Char]
myReverse []  = []
myReverse lst = myReverse' lst []

myReverse' :: String -> String -> String
myReverse' [] acc = acc
myReverse' (x:xs) acc = myReverse' xs (x:acc)


myReverse2 :: [a] -> [a]
myReverse2 []  = []
myReverse2 lst = myReverse2' lst []

myReverse2' :: [a] -> [a] -> [a]
myReverse2' [] acc = acc
myReverse2' (x:xs) acc = myReverse2' xs (x:acc)

myReverse3 :: [a] -> [a]
myReverse3 lst = rev lst []
   where rev [] acc = acc
         rev (x:xs) acc = rev xs (x:acc)

myReverse4 :: [a] -> [a]
myReverse4 lst =
  let
    rev [] acc = acc
    rev (x:xs) acc = rev xs (x:acc)
  in 
    rev lst []

-- example from the slides
-- Note: in the homework you must give explicit types
getFirst (x, y) = x
