[Haskell-beginners] Haskell type system

Peter Verswyvelen bugfact at gmail.com
Sun Sep 27 08:50:53 EDT 2009


Which parts would like explanations for? All of them?
On Sun, Sep 27, 2009 at 12:22 PM, informationen <informationen at gmx.de>wrote:

> 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090927/aaa65450/attachment-0001.html


More information about the Beginners mailing list