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.

47 lines
1.3 KiB

# Chapter Excercises
## Multiple choice
1. (c)
2. (a)
3. (b)
4. (c)
## Determine the type
1.
1. `Num a => a`
2. `Num a => (a, [Char])`
3. `(Integer, [Char])`
4. `Bool`
5. `Int`
6. `Bool`
2. `Num a => a`
3. `Num a => a -> a`
4. `Fractional a => a`
5. `[Char]`
## Does it compile?
1. The definition of `wahoo` tries to apply a `Num` to another `Num` which does not work. Either change `bigNum` to take an argument (`bigNum x = (^) 5 $ x ; wahoo = bigNum $ 10`) or fix `wahoo`, e.g. `wahoo = bigNum`
2.Nothing wrong here.
3. `c` tries to apply `5` to `b = 5` which does not work. It's also expected to take an argument in the definition of `d = c 200`. A fix could thus be: `c = a 10`.
4. `c` is not defined for the definition of `b`.
## Type variable or specific type constructor?
1. /
2. `zed` is fully polymorphic, `Zed` and `Blah` are concrete.
3. `a` is fully polymorphic, `b` is constrained and `C` is concrete.
4. `f` and `g` are fully polymorphic and `C` is concrete.
## Write a type signature
1. `functionH :: [a] -> a`
2. `functionC :: (Ord a) => a -> a -> Bool`
3. `functionS :: (a, b) -> b`
## Given a type, write the function
see src/defineFunc.hs
## Fix it
1. see src/sing.hs
2. see src/sing.hs
3. see src/arith3broken.hs
## Type-Kwon-Do
see src/typekwondo.hs