[@@ FStar.Tactics.Typeclasses.tcinstance]
val showable_list: a: Type -> printable a -> printable (list a)
instance showable_list (a:Type) (_ : printable a) : printable (list a) = {
  pp = (fun l -> brackets (separate_map comma pp l))
}
[@@ FStar.Tactics.Typeclasses.tcinstance]
val showable_list: a: Type -> printable a -> printable (list a)
[@@ FStar.Tactics.Typeclasses.tcinstance]
let showable_list (a: Type) (_: printable a) : printable (list a) =
{ pp = (fun l -> brackets (separate_map comma pp l)) }
Pulse.PP.fst.checked
Pulse.Typing.Env.fsti.checked Pulse.Typing.fst.checked Pulse.Syntax.Printer.fsti.checked Pulse.Syntax.Base.fsti.checked Pulse.Show.fst.checked prims.fst.checked FStar.Tactics.V2.fst.checked FStar.Tactics.Typeclasses.fsti.checked FStar.Tactics.fst.checked FStar.Stubs.Pprint.fsti.checked FStar.Reflection.V2.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked
Pulse.PP.fst
Pulse.PP.printable Pulse.PP.Mkprintable Prims.list FStar.Stubs.Pprint.brackets FStar.Stubs.Pprint.document Pulse.PP.separate_map FStar.Stubs.Pprint.comma Pulse.PP.pp
module Pulse.PP

include FStar.Stubs.Pprint

open FStar.Tactics
open FStar.Tactics.Typeclasses
open FStar.Stubs.Pprint
open Pulse.Typing
open Pulse.Syntax.Base
open Pulse.Syntax.Printer

open Pulse.Show

(* A helper to create wrapped text *)
val text : string -> FStar.Stubs.Pprint.document
let text (s:string) : FStar.Stubs.Pprint.document =
  flow (break_ 1) (words s)

(* Nests a document 2 levels deep, as a block. It inserts a hardline
before the doc, so if you want to format something as

  hdr
    subdoc
  tail

  you should write  hdr ^^ indent (subdoc) ^/^ tail.  Note the ^^ vs ^/^.
*)
val indent : document -> document
let indent d =
  nest 2 (hardline ^^ align d)

class printable (a:Type) = {
  pp : a -> Tac document;
}

(* Repurposing a show instance *)
let from_show #a {| d : tac_showable a |} : printable a = {
  pp = (fun x -> arbitrary_string (show x));
}

instance _ : printable string = from_show
instance _ : printable unit   = from_show
instance _ : printable bool   = from_show
instance _ : printable int    = from_show

instance _ : printable ctag = from_show

instance printable_option (a:Type) (_ : printable a) : printable (option a) = {
  pp = (function None -> doc_of_string "None"
                 | Some v -> doc_of_string "Some" ^/^ pp v);
}

// Cannot use Pprint.separate_map, it takes a pure func
private
let rec separate_map (sep: document) (f : 'a -> Tac document) (l : list 'a) : Tac document =
  match l with
  | [] -> empty
  | [x] -> f x
  | x::xs -> f x ^^ sep ^/^ separate_map sep f xs
[@@ FStar.Tactics.Typeclasses.tcinstance]
val showable_list: a: Type -> printable a -> printable (list a)
a: Type -> _: Pulse.PP.printable a -> Pulse.PP.printable (Prims.list a)