You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.3 KiB
1.3 KiB
Chapter Excercises
Multiple choice
- (c)
- (a)
- (b)
- (c)
Determine the type
Num a => a
Num a => (a, [Char])
(Integer, [Char])
Bool
Int
Bool
Num a => a
Num a => a -> a
Fractional a => a
[Char]
Does it compile?
- The definition of
wahoo
tries to apply aNum
to anotherNum
which does not work. Either changebigNum
to take an argument (bigNum x = (^) 5 $ x ; wahoo = bigNum $ 10
) or fixwahoo
, e.g.wahoo = bigNum
2.Nothing wrong here. c
tries to apply5
tob = 5
which does not work. It's also expected to take an argument in the definition ofd = c 200
. A fix could thus be:c = a 10
.c
is not defined for the definition ofb
.
Type variable or specific type constructor?
- /
zed
is fully polymorphic,Zed
andBlah
are concrete.a
is fully polymorphic,b
is constrained andC
is concrete.f
andg
are fully polymorphic andC
is concrete.
Write a type signature
functionH :: [a] -> a
functionC :: (Ord a) => a -> a -> Bool
functionS :: (a, b) -> b
Given a type, write the function
see src/defineFunc.hs
Fix it
- see src/sing.hs
- see src/sing.hs
- see src/arith3broken.hs
Type-Kwon-Do
see src/typekwondo.hs