comparison tests/newMessage.ur @ 1736:7ec8dab190a7

Better discovery of type class instances from recursive definitions
author Adam Chlipala <adam@chlipala.net>
date Wed, 02 May 2012 08:34:50 -0400
parents
children
comparison
equal deleted inserted replaced
1735:ec47f49c6aa3 1736:7ec8dab190a7
1 datatype message = NewQuestion of { Id : string}
2 | Something of {Blah : int}
3
4 fun showMessage (message : message) =
5 case message of
6 NewQuestion {Id = a} => a
7 | Something {Blah = x} => "blah"
8
9 val show_mes = mkShow showMessage
10
11 fun showTwoTuple [a] [b] (_ : show a) (_: show b) = mkShow (fn (two_tuple : {1:a, 2:b}) =>
12 "(" ^ show two_tuple.1 ^ ", " ^ show two_tuple.2 ^ ")"
13
14 )
15 val om = show (Something {Blah = 1}, Something {Blah = 2})