Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/noti0na1/gadtformat

Type-safe Format using GADT in OCaml
https://github.com/noti0na1/gadtformat

format gadt ocaml

Last synced: 3 months ago
JSON representation

Type-safe Format using GADT in OCaml

Awesome Lists containing this project

README

        

# GADTFormat

Type-safe Format using GADT in OCaml

## Example

```ocaml
open GADTFormat

(* "Digit: %d%s" *)
let fs0 r = lit "Digit: " @@ dig @@ str r

(* fs1 : int -> string -> string *)
let fs1 = sprintf @@ to_str fs0

(*
append format string:
"Digit: %d%s, Digit: %d%s"
*)
let fs2 r = fs0 @@ lit ", " @@ fs0 r

(* fs3 : int -> string -> int -> string -> string *)
let fs3 = printf @@ to_out fs2

let _ =
print_endline @@ fs1 3 "c";
fs3 1 "a" 2 "b\n"
```

## Licence

Distributed under the terms of [MIT License](LICENSE)

Copyright (c) 2018 noti0na1