summaryrefslogtreecommitdiff
path: root/src/expl_print.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-07-29 12:30:04 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-07-29 12:30:04 -0400
commit4cbbb0bb751dd9e9dae9d6b621e563ee5c7ae1b4 (patch)
tree13fe85f442a35d516a1591c98af5b85e0cf1f6b7 /src/expl_print.sml
parent21f2ec92093d2b00afe3d36476f20f45b4d4a194 (diff)
Add datatype import constructor annotations; datatypes through explify
Diffstat (limited to 'src/expl_print.sml')
-rw-r--r--src/expl_print.sml48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/expl_print.sml b/src/expl_print.sml
index 58508097..472d83ae 100644
--- a/src/expl_print.sml
+++ b/src/expl_print.sml
@@ -274,6 +274,22 @@ fun p_named x n =
else
string x
+fun p_datatype env (x, n, cons) =
+ let
+ val env = E.pushCNamed env x n (KType, ErrorMsg.dummySpan) NONE
+ in
+ box [string "datatype",
+ space,
+ string x,
+ space,
+ string "=",
+ space,
+ p_list_sep (box [space, string "|", space])
+ (fn (x, _, NONE) => string x
+ | (x, _, SOME t) => box [string x, space, string "of", space, p_con env t])
+ cons]
+ end
+
fun p_sgn_item env (sgi, _) =
case sgi of
SgiConAbs (x, n, k) => box [string "con",
@@ -294,6 +310,22 @@ fun p_sgn_item env (sgi, _) =
string "=",
space,
p_con env c]
+ | SgiDatatype x => p_datatype env x
+ | SgiDatatypeImp (x, _, m1, ms, x', _) =>
+ let
+ val m1x = #1 (E.lookupStrNamed env m1)
+ handle E.UnboundNamed _ => "UNBOUND_STR_" ^ Int.toString m1
+ in
+ box [string "datatype",
+ space,
+ string x,
+ space,
+ string "=",
+ space,
+ string "datatype",
+ space,
+ p_list_sep (string ".") string (m1x :: ms @ [x'])]
+ end
| SgiVal (x, n, c) => box [string "val",
space,
p_named x n,
@@ -392,6 +424,22 @@ fun p_decl env (dAll as (d, _) : decl) =
string "=",
space,
p_con env c]
+ | DDatatype x => p_datatype env x
+ | DDatatypeImp (x, _, m1, ms, x', _) =>
+ let
+ val m1x = #1 (E.lookupStrNamed env m1)
+ handle E.UnboundNamed _ => "UNBOUND_STR_" ^ Int.toString m1
+ in
+ box [string "datatype",
+ space,
+ string x,
+ space,
+ string "=",
+ space,
+ string "datatype",
+ space,
+ p_list_sep (string ".") string (m1x :: ms @ [x'])]
+ end
| DVal vi => box [string "val",
space,
p_vali env vi]