Skip to content

Instantly share code, notes, and snippets.

@adz
Created January 2, 2020 00:27
Show Gist options
  • Save adz/10a12a146c159e8420a04b0b8ce6017c to your computer and use it in GitHub Desktop.
Save adz/10a12a146c159e8420a04b0b8ce6017c to your computer and use it in GitHub Desktop.
type Response = { StatusCode : int }
// Simulate sync action, that returns count of records synced
let syncRecords upToTimestamp = ResultT <| async.Return (Ok 3)
// Simulate bookmark function, sending last timestamp synced to a rest api
let recordTimestamp upToTimestamp = async {
return {StatusCode = 200 }
}
let performSync () =
let utcNow = DateTime.UtcNow
monad {
let! count = syncRecords utcNow
let! response = recordTimestamp utcNow |> liftAsync
if response.StatusCode < 200 || response.StatusCode >= 300 then
printfn "Sync succeeded, but failed to update bookmark"
return count
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment