package async_rpc_kernel

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file or_not_authorized.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
open! Core

type 'a t =
  | Authorized of 'a
  | Not_authorized of Error.t

let bind t ~f =
  match t with
  | Authorized a -> f a
  | Not_authorized _ as t -> t
;;

let map t ~f = bind t ~f:(fun x -> Authorized (f x))

let bind_deferred t ~f =
  match t with
  | Authorized a -> f a
  | Not_authorized _ as t -> Eager_deferred.return t
;;

let map_deferred t ~f =
  bind_deferred t ~f:(fun a -> Eager_deferred.map (f a) ~f:(fun a -> Authorized a))
;;

let lift_deferred = map_deferred ~f:Fn.id