(*--------------------------------------------------------------------------- Copyright (c) 2026 Thomas Gazagnaire. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) type t = | Null | True | False | Int | Int5 | Float | Float5 | Text | Textj | Text5 | Textraw | Array | Object let of_code = function | 0 -> Some Null | 1 -> Some True | 2 -> Some False | 3 -> Some Int | 4 -> Some Int5 | 5 -> Some Float | 6 -> Some Float5 | 7 -> Some Text | 8 -> Some Textj | 9 -> Some Text5 | 10 -> Some Textraw | 11 -> Some Array | 12 -> Some Object | _ -> None let to_code = function | Null -> 0 | True -> 1 | False -> 2 | Int -> 3 | Int5 -> 4 | Float -> 5 | Float5 -> 6 | Text -> 7 | Textj -> 8 | Text5 -> 9 | Textraw -> 10 | Array -> 11 | Object -> 12 let to_string = function | Null -> "null" | True -> "true" | False -> "false" | Int -> "int" | Int5 -> "int5" | Float -> "float" | Float5 -> "float5" | Text -> "text" | Textj -> "textj" | Text5 -> "text5" | Textraw -> "textraw" | Array -> "array" | Object -> "object" let equal (a : t) b = a = b let pp ppf s = Fmt.string ppf (to_string s)