From 37113e8630b57d46f3fa5f5185e9a4c18c6871cd Mon Sep 17 00:00:00 2001 From: Maxime Levillain Date: Wed, 28 Aug 2024 10:43:27 +0200 Subject: [PATCH] pretty printer for ezEncoding --- src/encoding/ezEncoding.ml | 2 ++ src/encoding/ezEncoding.mli | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/encoding/ezEncoding.ml b/src/encoding/ezEncoding.ml index 78ef0da..bfea308 100644 --- a/src/encoding/ezEncoding.ml +++ b/src/encoding/ezEncoding.ml @@ -459,3 +459,5 @@ let ignore_enc encoding = let enc_constant enc v = conv (fun () -> v) (fun v2 -> if v2 = v then () else assert false) enc + +let pp ?compact enc fmt x = Format.fprintf fmt "%s" (construct ?compact enc x) diff --git a/src/encoding/ezEncoding.mli b/src/encoding/ezEncoding.mli index 67609e0..981b2b4 100644 --- a/src/encoding/ezEncoding.mli +++ b/src/encoding/ezEncoding.mli @@ -359,3 +359,5 @@ val result : 'a Json_encoding.encoding -> 'b Json_encoding.encoding -> val ignore_enc : 'a Json_encoding.encoding -> 'a Json_encoding.encoding val enc_constant : 'a Json_encoding.encoding -> 'a -> unit Json_encoding.encoding + +val pp : ?compact:bool -> 'a Json_encoding.encoding -> Format.formatter -> 'a -> unit