package bam-ppx

  1. Overview
  2. Docs

Source file ty.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
open Ppxlib

type _ ranged = Int : int ranged | Int32 : int32 ranged | Int64 : int64 ranged

let ranged_compare (type a1 a2) : a1 ranged -> a2 ranged -> (a1, a2) Dmap.cmp =
 fun left right ->
  match (left, right) with
  | Int, Int ->
      Dmap.Eq
  | Int32, Int32 ->
      Dmap.Eq
  | Int64, Int64 ->
      Dmap.Eq
  | Int, _ ->
      Lt
  | Int32, Int ->
      Gt
  | Int32, _ ->
      Lt
  | Int64, Int ->
      Gt
  | Int64, Int32 ->
      Gt

type 'continuation sized =
  | String : expression sized
  | Bytes : expression sized
  | List : (expression -> expression) sized
  | Array : (expression -> expression) sized
  | Seq : (expression -> expression) sized

type 'continuation t =
  | Unit : expression t
  | Bool : expression t
  | Char : expression t
  | Ranged : _ ranged -> expression t
  | Sized : 'continuation sized -> 'continuation t
  | Option : (expression -> expression) t
  | Any : expression t

module Ranged_dmap = Dmap.Make (struct
  type 'a t = 'a ranged

  let compare = ranged_compare
end)

type st = E : _ sized -> st

module Sized_map = Map.Make (struct
  type t = st

  let compare = compare
end)

type et = E : _ t -> et

module Map = Map.Make (struct
  type t = et

  let compare = compare
end)
OCaml

Innovation. Community. Security.