Mercurial > urweb
annotate tests/type_class.ur @ 419:cb5897276abf
Fix bug with bringing functor argument instances into scope; Ref demo, minus prose
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 23 Oct 2008 17:35:10 -0400 |
parents | 71bafe66dbe1 |
children | fab5998b840e |
rev | line source |
---|---|
adamc@211 | 1 class default t = t |
adamc@211 | 2 |
adamc@212 | 3 val string_default : default string = "Hi" |
adamc@211 | 4 val int_default : default int = 0 |
adamc@211 | 5 |
adamc@211 | 6 val default : t :: Type -> default t -> t = |
adamc@211 | 7 fn t :: Type => fn d : default t => d |
adamc@212 | 8 val hi = default [string] _ |
adamc@211 | 9 val zero = default [int] _ |
adamc@212 | 10 |
adamc@212 | 11 val frob : t :: Type -> default t -> t = |
adamc@212 | 12 fn t :: Type => fn _ : default t => default [t] _ |
adamc@212 | 13 val hi_again = frob [string] _ |
adamc@212 | 14 val zero_again = frob [int] _ |
adamc@212 | 15 |
adamc@212 | 16 val main : unit -> page = fn () => <html><body> |
adamc@212 | 17 {cdata hi_again} |
adamc@212 | 18 </body></html> |