Skip to content
This repository was archived by the owner on Jul 5, 2022. It is now read-only.
This repository was archived by the owner on Jul 5, 2022. It is now read-only.

Additional Result and Maybe functions #50

@nicholasjhenry

Description

@nicholasjhenry

‘’’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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions