From 210946aa1857eebde9b16a782cf293a83d2be008 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sat, 29 Oct 2011 17:30:34 -0400 Subject: Shorter, more focused error messages about undetermined unification variables --- src/elab_err.sml | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'src/elab_err.sml') diff --git a/src/elab_err.sml b/src/elab_err.sml index 00f1e4fc..84c8c61f 100644 --- a/src/elab_err.sml +++ b/src/elab_err.sml @@ -262,7 +262,55 @@ datatype decl_error = fun lspan [] = ErrorMsg.dummySpan | lspan ((_, loc) :: _) = loc -val p_decl = P.p_decl +val baseLen = 2000 + +fun p_decl env d = + let + val fname = OS.FileSys.tmpName () + val out' = TextIO.openOut fname + val out = Print.openOut {dst = out', wid = 80} + + fun readFromFile () = + let + val inf = TextIO.openIn fname + + fun loop acc = + case TextIO.inputLine inf of + NONE => String.concat (rev acc) + | SOME line => loop (line :: acc) + in + loop [] + before TextIO.closeIn inf + end + in + Print.fprint out (P.p_decl env d); + TextIO.closeOut out'; + let + val content = readFromFile () + in + OS.FileSys.remove fname; + Print.PD.string (if size content <= baseLen then + content + else + let + val (befor, after) = Substring.position "