Created
January 2, 2020 00:21
-
-
Save adz/a27b35200fec0d4e71120e028bbdb637 to your computer and use it in GitHub Desktop.
This file contains 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
// Simulate sync action, that returns count of records synced | |
let syncRecords upToTimestamp : ResultT<Async<Result<int,string>>> = ResultT <| async.Return (Ok 3) | |
let recordTimestampUsingFSData body : Async<FSharp.Data.HttpResponse> = | |
FSharp.Data.Http.AsyncRequest | |
( "https://myapi.example.com/sync" | |
, httpMethod = "POST" | |
, body = TextRequest (sprintf "%A" body) // actually is json | |
, silentHttpErrors = true ) | |
let performSync1 () = | |
let utcNow = DateTime.UtcNow | |
monad { | |
let! count = syncRecords utcNow | |
let responseRT = recordTimestampUsingFSData utcNow |> liftAsync | |
// This fails to compile with | |
// error FS0071: Type constraint mismatch when applying the default type 'obj' for a type inference variable. No overloads match for method 'LiftAsync'. | |
let! response = responseRT | |
// but compiles OK, if the following two lines are commented | |
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
If lines #23 and #24 are put under a
do
then it also compile.... struggling to understand that...