Skip to content

Commit 0e5dd2a

Browse files
authored
Merge pull request #344 from sideeffffect/master
add getOrFail and getOrRaise functions for Option
2 parents 4609d99 + c3b1eb1 commit 0e5dd2a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • src/FSharpx.Extras/ComputationExpressions

src/FSharpx.Extras/ComputationExpressions/Monad.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@ module Option =
226226
| Some x -> x
227227
| None -> v()
228228

229+
/// Gets the value associated with the option or fails with the supplied message.
230+
let inline getOrFail m =
231+
function
232+
| Some x -> x
233+
| None -> failwith m
234+
235+
/// Gets the value associated with the option or raises the supplied exception.
236+
let inline getOrRaise e =
237+
function
238+
| Some x -> x
239+
| None -> raise e
240+
229241
/// Gets the value associated with the option or the default value for the type.
230242
let getOrDefault =
231243
function

0 commit comments

Comments
 (0)