package mirage-tc

  1. Overview
  2. No Docs
MirageOS type-classes

Install

Dune Dependency

Authors

Maintainers

Sources

0.1.0.tar.gz
sha256=73032c4bf16fdf1c3ef84deab7034636665d79436b0737ae6eaa4f35850b419c
md5=93a51194b72381af02ac698501b5a275

Description

A set of functors and combinators to pretty-print (using sexplib), to convert to and from and JSON and Cstruct buffers.

# Tc.show (module Tc.S) "Hello world!";;
- : string = "\"Hello world!\""
# Tc.to_json (module Tc.App2(Tc.P)(Tc.I)(Tc.S)) (3, "foo");;
- : Ezjsonm.t = `A [`String "3"; `String "foo"]

A slightly more complex example, using autogen code instead of functor composition:

# camlp4o;;
# require "sexplib.syntax";;
# require "comparelib.syntax";;
# require "bin_prot.syntax";;
# module M = struct
    type t = { foo: int; bar: string list } with sexp, bin_prot, compare
  end;;
# module X = Tc.I0(M);;
# let t = { foo = 3; bar = [ "hello"; "world" ] };;

# Tc.to_json (module X) t;;
- : Ezjsonm.t =
`A
  [`A [`String "foo"; `String "3"];
   `A [`String "bar"; `A [`String "hello"; `String "world"]]]

# Tc.write_string (module X) t;;
- : string = "\003\002\005hello\005world"

Published: 31 Oct 2014

Dependencies (8)

  1. ocamlbuild build
  2. comparelib
  3. bin_prot < "113.01.00"
  4. sexplib < "113.01.00"
  5. cstruct
  6. mstruct >= "1.3.1"
  7. ezjsonm >= "0.3.0" & < "0.4.0"
  8. ocaml >= "4.01.0"

Dev Dependencies (2)

  1. ounit with-test
  2. alcotest with-test

Used by (1)

  1. datakit < "0.10.0"

Conflicts

None

OCaml

Innovation. Community. Security.