typinferenz.sh 912 B

123456789101112131415161718192021222324252627282930313233343536
  1. Prelude> let x = \x -> x*x
  2. Prelude> :t x
  3. x :: Integer -> Integer
  4. Prelude> x(2)
  5. 4
  6. Prelude> x(2.2)
  7. <interactive>:6:3:
  8. No instance for (Fractional Integer)
  9. arising from the literal `2.2'
  10. Possible fix: add an instance declaration for
  11. (Fractional Integer)
  12. In the first argument of `x', namely `(2.2)'
  13. In the expression: x (2.2)
  14. In an equation for `it': it = x (2.2)
  15. Prelude> let mult = \x y->x*y
  16. Prelude> mult(2,5)
  17. <interactive>:9:5:
  18. Couldn't match expected type `Integer' with
  19. actual type `(t0, t1)'
  20. In the first argument of `mult', namely `(2, 5)'
  21. In the expression: mult (2, 5)
  22. In an equation for `it': it = mult (2, 5)
  23. Prelude> mult 2 5
  24. 10
  25. Prelude> :t mult
  26. mult :: Integer -> Integer -> Integer
  27. Prelude> let concat = \x y -> x ++ y
  28. Prelude> concat [1,2,3] [3,2,1]
  29. [1,2,3,3,2,1]
  30. Prelude> :t concat
  31. concat :: [a] -> [a] -> [a]