From 9d94ce72c16439f13b6cd3f9c97ce2afcb8c4b57 Mon Sep 17 00:00:00 2001 From: Ed Ilyin Date: Thu, 6 Jul 2017 17:13:25 +0300 Subject: [PATCH] Bump version to 0.1.0 --- RELEASE_NOTES.md | 3 +++ paket.lock | 4 +-- src/EdIlyin.FSharp.Http/AssemblyInfo.fs | 8 +++--- src/EdIlyin.FSharp.Http/Response.fs | 33 +++++++++++++++---------- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d097e0e..046a869 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +### 0.1.0 - Jule 6 2017 +* moves to built-in Result + ### 0.0.5 - June 29 2017 * adds delete method diff --git a/paket.lock b/paket.lock index be94a46..c35450f 100644 --- a/paket.lock +++ b/paket.lock @@ -6,10 +6,10 @@ NUGET Chiron (6.2.1) Aether (>= 8.0.2 < 9.0) FParsec (>= 1.0 < 2.0) - EdIlyin.FSharp.Boxcar (0.0.5) + EdIlyin.FSharp.Boxcar (0.0.6) EdIlyin.FSharp.Elm.Core Hopac - EdIlyin.FSharp.Elm.Core (1.0.28) + EdIlyin.FSharp.Elm.Core (2.1) Chiron FSharp.Core FParsec (1.0.2) diff --git a/src/EdIlyin.FSharp.Http/AssemblyInfo.fs b/src/EdIlyin.FSharp.Http/AssemblyInfo.fs index 5922ca1..5fb15c3 100644 --- a/src/EdIlyin.FSharp.Http/AssemblyInfo.fs +++ b/src/EdIlyin.FSharp.Http/AssemblyInfo.fs @@ -5,8 +5,8 @@ open System.Reflection [] [] [] -[] -[] +[] +[] [] do () @@ -14,6 +14,6 @@ module internal AssemblyVersionInformation = let [] AssemblyTitle = "EdIlyin.FSharp.Http" let [] AssemblyProduct = "EdIlyin.FSharp.Http" let [] AssemblyDescription = "HTTP decoders" - let [] AssemblyVersion = "0.0.5" - let [] AssemblyFileVersion = "0.0.5" + let [] AssemblyVersion = "0.1.0" + let [] AssemblyFileVersion = "0.1.0" let [] AssemblyConfiguration = "Release" diff --git a/src/EdIlyin.FSharp.Http/Response.fs b/src/EdIlyin.FSharp.Http/Response.fs index f5d5d15..3173562 100644 --- a/src/EdIlyin.FSharp.Http/Response.fs +++ b/src/EdIlyin.FSharp.Http/Response.fs @@ -8,35 +8,42 @@ open FSharp.Data module Response = let statusCode expecting = - Decode.satisfy - (fun (r:HttpResponse) -> r => Some r.StatusCode) - (fun sc -> if sc = expecting then Ok sc else Err sc) - (sprintf "status code %A" expecting) + let label = sprintf "a status code %A" expecting + + Decode.primitive label + (fun (r:HttpResponse) -> + let sc = r.StatusCode + if sc = expecting then Decode.Decoded sc + else label => r |> Decode.ExpectingButGot + ) let bodyText = - Decode.satisfy (fun (r:HttpResponse) -> r, Some r.Body) - (fun body -> - match body with - | Binary _ -> Err "binary body" - | Text text -> Ok text + let label = "text body" + + Decode.primitive label + (fun (r:HttpResponse) -> + match r.Body with + | Binary _ -> label => r |> Decode.ExpectingButGot + | Text text -> Decode.Decoded text ) - "text body" let unpack parser async = boxcar { let! response = Job.fromAsync async |> Boxcar.catch - return! + let! result = try do printfn "Response %i from %s" response.StatusCode response.ResponseUrl - Decode.parseAny parser response + Decode.decode parser response with | exn -> - sprintf "%s\n%A" exn.Message response |> Err + sprintf "%s\n%A" exn.Message response |> Error |> Boxcar.fromResult + + return result }