Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 823 Bytes

README.md

File metadata and controls

44 lines (30 loc) · 823 Bytes

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