Last active
August 29, 2015 14:25
-
-
Save keleshev/16097f71e9edaa08abcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include (struct | |
type 'a t = 'a * string list | |
exception FatalWarning of string list | |
let to_exn: 'a t -> 'a = function | |
| value, [] -> value | |
| value, warnings -> raise (FatalWarning warnings) | |
let map f (value, warnings) = f value, warnings | |
let of_option replacement warning = function | |
| Some value -> value, [] | |
| None -> replacement, [warning] | |
let ok value = value, [] | |
let warned value warning = value, [warning] | |
let create ?(warnings=[]) value = value, warnings | |
end: sig | |
type 'a t | |
exception FatalWarning of string list | |
val to_exn: 'a t -> 'a | |
val map: ('a -> 'b) -> 'a t -> 'b t | |
val of_option: 'a -> string -> 'a option -> 'a t | |
val ok: 'a -> 'a t | |
val warned: 'a -> string -> 'a t | |
val create: ?warnings:string list -> 'a -> 'a t | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment