Skip to content

BenBeattieHood/FSharpResult

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FSharpResult

General validation functions and monad

Usage:

open Result

let getUser id =
    DB.getUser id
    |> Validation.ofOption "Cannot load user"

    
let displayNameResult =
    result {
        let! user = getUser 32

        return sprintf "%s %s" user.firstName user.lastName
    }


match displayNameResult with
| Ok displayName ->
    displayName
    |> sprintf "Hi %s!"

| Error error ->
    error
    |> sprintf "Error: %s"

|> System.Console.WriteLine

Huge thanks to the FSharpx validated code, which this is really just a rehash of, minus some bits I didn't agree with (Choice), plus some helpful things around options and sequences.

About

General validation functions and monad

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages