File: option_ext.ml

package info (click to toggle)
ocaml-multicore-bench 0.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 320 kB
  • sloc: ml: 1,476; sh: 60; makefile: 6
file content (20 lines) | stat: -rw-r--r-- 518 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
let pair x y = match (x, y) with Some x, Some y -> Some (x, y) | _ -> None

module Syntax = struct
  let ( & ) l r x =
    match l x with
    | None -> None
    | Some l -> begin
        match r x with None -> None | Some r -> Some Infix_pair.(l :: r)
      end

  let ( let* ) = Option.bind
  let ( >>= ) = Option.bind
  let ( >=> ) f g x = f x >>= g
  let ( let+ ) x f = Option.map f x
  let ( >>+ ) = ( let+ )
  let ( >+> ) f g x = f x >>+ g
  let pure = Option.some
  let ( and* ) = pair
  let ( and+ ) = pair
end