Source file utils.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
let ( >> ) f g x = g (f x)

module List = struct
  include List

  let rec intersperse ~sep = function
    | ([] | [ _ ]) as l -> l
    | h1 :: (_ :: _ as tl) -> h1 :: sep :: intersperse ~sep tl
end

module Staging : sig
  type 'a staged

  val stage : 'a -> 'a staged
  val unstage : 'a staged -> 'a
  val ( let$ ) : 'a staged -> ('a -> 'b) -> 'b staged
  val ( and$ ) : 'a staged -> 'b staged -> ('a * 'b) staged
end = struct
  type 'a staged = 'a

  let stage a = a
  let unstage a = a
  let ( let$ ) x f = f x
  let ( and$ ) a b = (a, b)
end