demo
[cc1516.git] / examples / old / Markus / identity(2).spl
1 //// Various versions of the identity function//
2
3 // Identity for integers
4 // The type signature forces the function to have a more concrete type than it could have.
5 id_int(x) :: Int -> Int
6 {
7 return x;
8 }//
9 ////
10
11 // Polymorphic identity with type signature
12 id_poly_with(x) :: a -> a
13 {
14 return x;
15 }//////
16
17
18 // Polymorphic identity without type signature
19 // Type checking should figure out the type forall a . a -> a
20 id_poly_without(x)
21 {
22 return x;
23 }//
24
25
26 // Clumsy polymorphic identity
27 // Type checking should give type forall a . a -> a
28 id_poly_wtf(x)
29 {
30 var a = x;
31 var b = a;
32 var c = b;
33 return c;
34 }//
35
36
37 // Clumsy identity for integers
38 // Type checking should give type Int -> Int
39 id_int_wtf(x)
40 {
41 var a = x;
42 Int b = a;
43 var c = b;
44 return c;
45 }
46
47 main() {return;}