summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2012-05-02 08:34:50 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2012-05-02 08:34:50 -0400
commitb314c01095c5cd4617f71f706e43530a57ffb65b (patch)
tree88076906dd1130c5cfd2657d40e8641aac59c0e7
parenta612a0c55bed76b4192fb66ffeba43933bcfb6bf (diff)
Better discovery of type class instances from recursive definitions
-rw-r--r--src/elaborate.sml5
-rw-r--r--tests/newMessage.ur15
2 files changed, 19 insertions, 1 deletions
diff --git a/src/elaborate.sml b/src/elaborate.sml
index 852ba2b2..26ec21ec 100644
--- a/src/elaborate.sml
+++ b/src/elaborate.sml
@@ -3912,8 +3912,11 @@ and elabDecl (dAll as (d, loc), (env, denv, gs)) =
expError env (IllegalRec (x, e'));
((x, n, c', e'), gs1 @ gs)
end) gs vis
+
+ val vis = map (fn (x, n, t, e) => (x, n, normClassConstraint env t, e)) vis
+ val d = (L'.DValRec vis, loc)
in
- ([(L'.DValRec vis, loc)], (env, denv, gs))
+ ([d], (E.declBinds env d, denv, gs))
end
| L.DSgn (x, sgn) =>
diff --git a/tests/newMessage.ur b/tests/newMessage.ur
new file mode 100644
index 00000000..e6ae3b4e
--- /dev/null
+++ b/tests/newMessage.ur
@@ -0,0 +1,15 @@
+datatype message = NewQuestion of { Id : string}
+ | Something of {Blah : int}
+
+fun showMessage (message : message) =
+ case message of
+ NewQuestion {Id = a} => a
+ | Something {Blah = x} => "blah"
+
+val show_mes = mkShow showMessage
+
+fun showTwoTuple [a] [b] (_ : show a) (_: show b) = mkShow (fn (two_tuple : {1:a, 2:b}) =>
+ "(" ^ show two_tuple.1 ^ ", " ^ show two_tuple.2 ^ ")"
+
+ )
+val om = show (Something {Blah = 1}, Something {Blah = 2})