
I have found this online book to be fairly easy to understand
http://book.realworldhaskell.org/read/types-and-functions.html
http://book.realworldhaskell.org/read/types-and-functions.htmlTake a look
at the section called "The type of a function with more than one argument"
and also follow the link to "Partial function application and currying"
If you decide to use this book, I would recommend reading the entire thing.
I tried to skip around at first, but got lost pretty quickly. The author
does a good job of adding complexity step by step, so it might be best to
start from the beginning.
On Sun, Sep 27, 2009 at 3:22 AM, informationen
Hi,
i am trying to understand the Haskell type system. I thought i understood it quite well until i encountered the three following exercises. As you can see, i have the answers already. But i don't understand, why they are correct.
Could anybody tell me a good place where i could learn how to answers these kind of questions correctly or could give me some explanations, why these answers are correct?
Any help is highly appreciated.
Kind regards
Chris Two functions f and g with the following signatures are given: f :: a -> a g :: b -> c -> b
A) Give the type of the following expressions:
1) g [False] True :: 2) g [] True :: 3) g (f True) :: 4) g f :: Answers:
1 [Boolean] 2) [a] 3) c -> Bool 4) c -> (a -> a)1) g f 1 B) Which of the following statements is correct?
2) g (f 1) is type correct 3) g . (f 1) is type correct 4) g . f 1 is type correct 5) (g . f) 1 is type correct 6) none of the expressions is correct
Answers: 1,2 and 5 are correct.
C) A function h is given as: h p x = p (f x). Which of the following statements is correct.
1) h :: a -> b -> a -> b 2) h :: (a -> a) -> a -> a 3) h :: (a -> b) -> a -> b 4) h is equivalent to h' with h' p = p . f 5) h is equivalent to h' with h' p = p f 5) h is equivalent to h' with h' p x = p f x
Answers: (I am not sure, if i remember correctly, but 3) and 4) should be correct.)
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners