Mercurial > urweb
comparison tests/type_classMod2.lac @ 218:a3413288cce1
Signature ascription for type classes
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 16 Aug 2008 16:57:21 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
217:56db662ebcfd | 218:a3413288cce1 |
---|---|
1 signature S = sig | |
2 class c | |
3 val default : t :: Type -> c t -> t | |
4 | |
5 val string_c : c string | |
6 val int_c : c int | |
7 end | |
8 | |
9 structure M : S = struct | |
10 class c t = t | |
11 val default = fn t :: Type => fn v : c t => v | |
12 | |
13 val int_c : c int = 0 | |
14 val string_c : c string = "Hi" | |
15 end | |
16 | |
17 val hi = M.default [string] _ | |
18 val zero = M.default [int] _ |