package vcaml

  1. Overview
  2. Docs

Source file types.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
open! Base

module type Nvim_ext = sig
  type t [@@deriving compare, hash, sexp]

  val equal : t -> t -> bool
  val of_msgpack : Msgpack.t -> t Or_error.t
  val to_msgpack : t -> Msgpack.t
end

module Buffer = struct
  type t = int [@@deriving equal, hash, compare, sexp]

  let of_msgpack = function
    | Msgpack.Integer i -> Ok i
    | Int64 _ | UInt64 _ -> Or_error.error_string "too many buffers!"
    | _ -> Or_error.error_string "Expected int when deserializing buffer"
  ;;

  let to_msgpack i = Msgpack.Integer i
end

module Window = struct
  type t = int [@@deriving equal, hash, compare, sexp]

  let of_msgpack = function
    | Msgpack.Integer i -> Ok i
    | Int64 _ | UInt64 _ -> Or_error.error_string "too many windows!"
    | _ -> Or_error.error_string "Expected int when deserializing window"
  ;;

  let to_msgpack i = Msgpack.Integer i
end

module Tabpage = struct
  type t = Int64.t [@@deriving equal, hash, compare, sexp]

  let of_msgpack = function
    | Msgpack.Integer i -> Ok (Int64.of_int i)
    | Int64 i | UInt64 i -> Ok i
    | _ -> Or_error.error_string "Expected int when deserializing tabpage"
  ;;

  let to_msgpack i = Msgpack.Int64 i
end

module Phantom = struct
  type _ t =
    | Nil : unit t
    | Integer : int t
    | Boolean : bool t
    | Array : 'a t -> 'a list t
    | Tuple : 'a t * int -> 'a list t
    | Dict : (Msgpack.t * Msgpack.t) list t
    | String : string t
    | Buffer : Buffer.t t
    | Tabpage : Tabpage.t t
    | Window : Window.t t
    | Object : Msgpack.t t
    | Custom :
        { of_msgpack : Msgpack.t -> 'a Or_error.t
        ; to_msgpack : 'a -> Msgpack.t
        }
        -> 'a t
end

type 'result api_result =
  { name : string
  ; params : Msgpack.t
  ; witness : 'result Phantom.t
  }
OCaml

Innovation. Community. Security.