Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132937 views
License: OTHER
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
16
17
Prelude> let mult = \x y->x*y
18
Prelude> mult(2,5)
19
<interactive>:9:5:
20
Couldn't match expected type `Integer' with
21
actual type `(t0, t1)'
22
In the first argument of `mult', namely `(2, 5)'
23
In the expression: mult (2, 5)
24
In an equation for `it': it = mult (2, 5)
25
Prelude> mult 2 5
26
10
27
Prelude> :t mult
28
mult :: Integer -> Integer -> Integer
29
30
Prelude> let concat = \x y -> x ++ y
31
Prelude> concat [1,2,3] [3,2,1]
32
[1,2,3,3,2,1]
33
Prelude> :t concat
34
concat :: [a] -> [a] -> [a]
35
36
37