Skip to content

noti0na1/GADTFormat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GADTFormat

Type-safe Format using GADT in OCaml

Example

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

Copyright (c) 2018 noti0na1

About

Type-safe Format using GADT in OCaml

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published