F# computation expression based on railway programming
F# Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
AttemptIt.nuspec
LICENSE
README.md
appveyor.yml
build.bat
build.fsx

README.md

AttemptIt

F# computation expression based on railway programming http://fsharpforfunandprofit.com/posts/recipe-part2/

Build Status

Build status

Nuget

https://www.nuget.org/packages/AttemptIt

Types

  • Attempt<'TSuccess, 'TFail> represents an attempt at doing something
  • Result<'TSuccess, 'TFail> represents the result of an attempt

Syntax

Basic usage

let doThis = attempt {
    let! x = someFunc()
    let! y = someOtherFunc y
    return! finalFunc y
}

Catching Exceptions

let exceptionHandler (e:exn) -> Fail e.Message
let tryThis = Attempt.Catch exceptionHandler doThis

Evaluating

let result = Attempt.Run tryThis