Mercurial > urweb
diff src/core_print.sml @ 626:230654093b51
demo/hello compiles with kind polymorphism
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 22 Feb 2009 17:17:01 -0500 |
parents | 588b9d16b00a |
children | 70cbdcf5989b |
line wrap: on
line diff
--- a/src/core_print.sml Sun Feb 22 16:33:55 2009 -0500 +++ b/src/core_print.sml Sun Feb 22 17:17:01 2009 -0500 @@ -38,22 +38,33 @@ val debug = ref false -fun p_kind' par (k, _) = +fun p_kind' par env (k, _) = case k of KType => string "Type" - | KArrow (k1, k2) => parenIf par (box [p_kind' true k1, + | KArrow (k1, k2) => parenIf par (box [p_kind' true env k1, space, string "->", space, - p_kind k2]) + p_kind env k2]) | KName => string "Name" - | KRecord k => box [string "{", p_kind k, string "}"] + | KRecord k => box [string "{", p_kind env k, string "}"] | KUnit => string "Unit" | KTuple ks => box [string "(", - p_list_sep (box [space, string "*", space]) p_kind ks, + p_list_sep (box [space, string "*", space]) (p_kind env) ks, string ")"] -and p_kind k = p_kind' false k + | KRel n => ((if !debug then + string (E.lookupKRel env n ^ "_" ^ Int.toString n) + else + string (E.lookupKRel env n)) + handle E.UnboundRel _ => string ("UNBOUND_REL" ^ Int.toString n)) + | KFun (x, k) => box [string x, + space, + string "-->", + space, + p_kind (E.pushKRel env x) k] + +and p_kind env = p_kind' false env fun p_con' par env (c, _) = case c of @@ -66,7 +77,7 @@ space, string "::", space, - p_kind k, + p_kind env k, space, string "->", space, @@ -105,7 +116,7 @@ space, string "::", space, - p_kind k, + p_kind env k, space, string "=>", space, @@ -123,7 +134,7 @@ space, p_con env c]) xcs, string "]::", - p_kind k]) + p_kind env k]) else parenIf par (box [string "[", p_list (fn (x, c) => @@ -147,6 +158,21 @@ | CProj (c, n) => box [p_con env c, string ".", string (Int.toString n)] + + | CKAbs (x, c) => box [string x, + space, + string "==>", + space, + p_con (E.pushKRel env x) c] + | CKApp (c, k) => box [p_con env c, + string "[[", + p_kind env k, + string "]]"] + | TKFun (x, c) => box [string x, + space, + string "-->", + space, + p_con (E.pushKRel env x) c] and p_con env = p_con' false env @@ -252,7 +278,7 @@ space, string "::", space, - p_kind k, + p_kind env k, space, string "=>", space, @@ -402,6 +428,16 @@ p_exp env e, string "]"] + | EKAbs (x, e) => box [string x, + space, + string "==>", + space, + p_exp (E.pushKRel env x) e] + | EKApp (e, k) => box [p_exp env e, + string "[[", + p_kind env k, + string "]]"] + and p_exp env = p_exp' false env fun p_named x n = @@ -480,7 +516,7 @@ space, string "::", space, - p_kind k, + p_kind env k, space, string "=", space,