20 lines
656 B
OCaml
20 lines
656 B
OCaml
module Lump : sig
|
|
include Irmin.Type.S
|
|
val v : string -> t
|
|
val timestamp : t -> int
|
|
end = struct
|
|
type t = { names : string list; value : string }
|
|
let compare x y = compare x.names y.names
|
|
let v names value = { names ; value }
|
|
let names t = t.names
|
|
let pp ppf { names; message } = Fmt.pf ppf "%04d: %s" timestamp message
|
|
let t =
|
|
let open Irmin.Type in
|
|
record "entry" (fun t32 message ->
|
|
{ timestamp = Int32.to_int t32; message })
|
|
|+ field "timestamp" int32 (fun t -> Int32.of_int t.timestamp)
|
|
|+ field "message" string (fun t -> t.message)
|
|
|> sealr
|
|
let t = Irmin.Type.like ~cli:(pp, of_string) ~compare t
|
|
end
|