‘’’fsharp let getUpperText path = path |> Some |> Option.filter File.Exists |> Option.map (File.ReadAllText >> getUpper) |> Option.defaultIfNone "DEFAULT" module Result = // ('a -> bool) -> 'a -> Result<'a, 'a> let split f x = if f x then Success x else Failure x // ('a -> 'b) -> ('c -> 'b) -> Result<'a, 'c> -> 'b let either f g = function | Success succ -> f succ | Failure fail -> g fail ‘’’ https://hexdocs.pm/fe/FE.Maybe.html#content
‘’’fsharp
let getUpperText path =
path
|> Some
|> Option.filter File.Exists
|> Option.map (File.ReadAllText >> getUpper)
|> Option.defaultIfNone "DEFAULT"
module Result =
// ('a -> bool) -> 'a -> Result<'a, 'a>
let split f x = if f x then Success x else Failure x
‘’’
https://hexdocs.pm/fe/FE.Maybe.html#content