5 let pp_binder = function
11 let rec pp_term = function
12 | LocatedTerm ((p_begin, p_end), term) ->
13 sprintf "[%d,%d]%s" p_begin p_end (pp_term term)
15 | Appl terms -> sprintf "(%s)" (String.concat " " (List.map pp_term terms))
16 | Binder (kind, var, typ, body) ->
17 sprintf "\\%s %s%s.%s" (pp_binder kind) var
18 (match typ with None -> "" | Some typ -> ": " ^ pp_term typ)
20 | Case (term, typ, patterns) ->
21 sprintf "%smatch %s with %s"
22 (match typ with None -> "" | Some t -> sprintf "<%s>" (pp_term t))
23 (pp_term term) (pp_patterns patterns)
24 | LetIn (name, t1, t2) ->
25 sprintf "let %s = %s in %s" name (pp_term t1) (pp_term t2)
26 | LetRec (definitions, term) ->
27 sprintf "let rec %s in %s"
28 (String.concat " and "
30 (fun (name, body, typ, index) ->
31 sprintf "%s%s = %s" name
32 (match typ with None -> "" | Some typ -> ": " ^ pp_term typ)
36 | Ident (name, []) -> name
37 | Ident (name, substs) -> sprintf "%s[%s]" name (pp_substs substs)
38 | Meta (name, substs) ->
41 (List.map (function None -> "_" | Some term -> pp_term term) substs))
42 | Int num -> string_of_int num
44 and pp_subst (name, term) = sprintf "%s := %s" name (pp_term term)
45 and pp_substs substs = String.concat "; " (List.map pp_subst substs)
47 and pp_pattern (names, term) =
51 | names -> "(" ^ String.concat " " names ^ ")")
54 and pp_patterns patterns =
55 sprintf "[%s]" (String.concat " | " (List.map pp_pattern patterns))