package preface

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

Source file try.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
type 'a t = ('a, exn) Result.t

let pure x = Ok x
let ok = pure
let error exn = Error exn

include Result.Mono (Exn)

let capture f = try ok (f ()) with exn -> error exn
let case f g = function Ok x -> f x | Error exn -> g exn

let to_validation = function
  | Ok x -> Validation.valid x
  | Error exn -> Validation.invalid (Nonempty_list.create exn)
;;

let equal f = Result.equal f Exn.equal
let pp pp' = Result.pp pp' Exn.pp
OCaml

Innovation. Community. Security.