I have the following Stack module:
module type STACK = sig
type 'a t
exception Empty
val empty : 'a t
val push : 'a -> 'a t -> 'a t
val ppf :
(Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit
end
module ListStack : STACK = struct
type 'a t = 'a list
exception Empty
let empty = []
let push x s = x :: s
let ppf elt fmt s =
let open Format in
let pp_break fmt () = fprintf fmt "[@," in
pp_print_list ~pp_sep:pp_break elt fmt s
end
let stack = ListStack.(empty |> push 1)
I’m not able to figure out a way to print my stack,
let () = printf "%a" ListStack.ppf stack
gives errors, is there proper way to print it?