Created
January 2, 2020 00:27
-
-
Save adz/10a12a146c159e8420a04b0b8ce6017c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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