Commit 6a32b989 authored by POTTIER Francois's avatar POTTIER Francois

Printer improvements.

parent b6c8894b
......@@ -9,8 +9,15 @@ let indentation = 2
let block opening contents closing =
group (opening ^^ nest indentation (contents) ^^ closing)
let oblock opening contents =
block opening contents empty
(* -------------------------------------------------------------------------- *)
(* Bindings, or annotations: [x : t]. *)
let spacecolon =
string " :"
let binding x t =
block (x ^^ spacecolon) (space ^^ t) empty
(* -------------------------------------------------------------------------- *)
......
......@@ -9,8 +9,15 @@ let indentation = 2
let block opening contents closing =
group (opening ^^ nest indentation (contents) ^^ closing)
let oblock opening contents =
block opening contents empty
(* -------------------------------------------------------------------------- *)
(* Bindings, or annotations: [x : t]. *)
let spacecolon =
string " :"
let binding x t =
block (x ^^ spacecolon) (space ^^ t) empty
(* -------------------------------------------------------------------------- *)
......
......@@ -5,6 +5,9 @@ open F
let arrow =
string "->"
let doublebackslash =
string "\\\\"
let forall =
string "forall"
......@@ -28,18 +31,13 @@ and typ2 ty =
match ty with
| TyArrow (ty1, ty2) ->
group (typ1 ty1 ^/^ arrow ^/^ typ2 ty2)
| _ ->
typ1 ty
and typ3 ty =
match ty with
| TyForall (x, ty) ->
group (forall ^/^ string x ^^ dot ^/^ typ3 ty)
group (forall ^/^ string x ^^ dot ^/^ typ2 ty)
| _ ->
typ2 ty
typ1 ty
and typ ty =
typ3 ty
typ2 ty
let rec term0 t =
match t with
......@@ -68,27 +66,32 @@ and term1 t =
and term2 t =
match t with
| TePair (t1, t2) ->
term1 t1 ^^ comma ^/^ term2 t2
group (term1 t1 ^^ comma ^/^ term2 t2)
| _ ->
term1 t
and term3 t =
match t with
| TeAbs (x, ty, t) ->
oblock
(backslash ^^ string x ^^ colon ^^ typ ty ^^ dot)
(term3 t)
block
(backslash ^^ string x ^^ spacecolon)
(break 1 ^^ typ ty)
(break 1 ^^ dot)
^/^
term3 t
| TeLet (x, t1, t2) ->
block
(string "let" ^/^ string x ^/^ equals)
(string "let" ^/^ string x ^/^ equals ^^ space)
(term t1)
(string "in")
(string " in")
^/^
term t2
| TeTyAbs (a, t) ->
oblock
(backslash ^^ backslash ^^ string a ^^ dot)
(term3 t)
group (
doublebackslash ^^ string a ^^ space ^^ dot
^/^
term3 t
)
| _ ->
term2 t
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment