comparison tests/type_class.lac @ 212:ba4d7c33a45f

Testing type-class-parameterized functions
author Adam Chlipala <adamc@hcoop.net>
date Sat, 16 Aug 2008 14:36:17 -0400
parents e86411f647c6
children
comparison
equal deleted inserted replaced
211:e86411f647c6 212:ba4d7c33a45f
1 class default t = t 1 class default t = t
2 2
3 val string_default : default string = "" 3 val string_default : default string = "Hi"
4 val int_default : default int = 0 4 val int_default : default int = 0
5 5
6 val default : t :: Type -> default t -> t = 6 val default : t :: Type -> default t -> t =
7 fn t :: Type => fn d : default t => d 7 fn t :: Type => fn d : default t => d
8 val empty = default [string] _ 8 val hi = default [string] _
9 val zero = default [int] _ 9 val zero = default [int] _
10
11 val frob : t :: Type -> default t -> t =
12 fn t :: Type => fn _ : default t => default [t] _
13 val hi_again = frob [string] _
14 val zero_again = frob [int] _
15
16 val main : unit -> page = fn () => <html><body>
17 {cdata hi_again}
18 </body></html>