-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from inhabitedtype/optional-thunk
Optional thunk
- Loading branch information
Showing
5 changed files
with
52 additions
and
35 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
type t = unit -> unit | ||
|
||
let none = Sys.opaque_identity (fun () -> ()) | ||
let some f = | ||
if f == none | ||
then failwith "Optional_thunk: this function is not representable as a some value"; | ||
f | ||
|
||
let is_none t = t == none | ||
let is_some t = not (is_none t) | ||
let unchecked_value t = t |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
type t | ||
|
||
val none : t | ||
val some : (unit -> unit) -> t | ||
|
||
val is_none : t -> bool | ||
val is_some : t -> bool | ||
|
||
val unchecked_value : t -> unit -> unit |
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
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