Skip to content

Commit

Permalink
Merge pull request #140 from slamdata/type-unsafe-coercions
Browse files Browse the repository at this point in the history
Type unsafe coercions
  • Loading branch information
garyb committed Sep 5, 2019
2 parents e286329 + 474818b commit d5a7a9c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
16 changes: 8 additions & 8 deletions package.json
Expand Up @@ -6,13 +6,13 @@
"test": "eslint src && pulp test"
},
"devDependencies": {
"eslint": "^3.10.1",
"body-parser": "^1.15.2",
"express": "^4.14.0",
"pulp": "^11.0.0",
"purescript-psa": "^0.5.0",
"purescript": "^0.12.0",
"rimraf": "^2.5.4",
"xhr2": "^0.1.3"
"eslint": "^6.3.0",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"pulp": "^13.0.0",
"purescript-psa": "^0.7.3",
"purescript": "^0.13.3",
"rimraf": "^3.0.0",
"xhr2": "^0.2.0"
}
}
2 changes: 0 additions & 2 deletions src/Affjax.js
@@ -1,6 +1,4 @@
/* global exports */
/* global XMLHttpRequest */
/* global module */
/* global process */
"use strict";

Expand Down
18 changes: 11 additions & 7 deletions src/Affjax.purs
Expand Up @@ -30,6 +30,7 @@ import Data.Argonaut.Core (Json)
import Data.Argonaut.Core as J
import Data.Argonaut.Parser (jsonParser)
import Data.Array as Arr
import Data.ArrayBuffer.Types (ArrayView)
import Data.Either (Either(..), either)
import Data.Foldable (any)
import Data.FormURLEncoded as FormURLEncoded
Expand All @@ -49,6 +50,9 @@ import Effect.Exception (Error, error)
import Effect.Ref as Ref
import Foreign (F, Foreign, ForeignError(..), fail, unsafeReadTagged, unsafeToForeign)
import Math as Math
import Web.DOM (Document)
import Web.File.Blob (Blob)
import Web.XHR.FormData (FormData)

-- | A record that contains all the information to perform an HTTP request.
-- | Instead of constructing the record from scratch it is often easier to build
Expand Down Expand Up @@ -266,13 +270,13 @@ request req = do

extractContent :: RequestBody.RequestBody -> Foreign
extractContent = case _ of
RequestBody.ArrayView f → f unsafeToForeign
RequestBody.Blob x → unsafeToForeign x
RequestBody.Document x → unsafeToForeign x
RequestBody.String x → unsafeToForeign x
RequestBody.FormData x → unsafeToForeign x
RequestBody.FormURLEncoded x → unsafeToForeign (FormURLEncoded.encode x)
RequestBody.Json x → unsafeToForeign (J.stringify x)
RequestBody.ArrayView f → f (unsafeToForeign :: forall a. ArrayView a -> Foreign)
RequestBody.Blob x → (unsafeToForeign :: Blob -> Foreign) x
RequestBody.Document x → (unsafeToForeign :: Document -> Foreign) x
RequestBody.String x → (unsafeToForeign :: String -> Foreign) x
RequestBody.FormData x → (unsafeToForeign :: FormData -> Foreign) x
RequestBody.FormURLEncoded x → (unsafeToForeign :: String -> Foreign) (FormURLEncoded.encode x)
RequestBody.Json x → (unsafeToForeign :: String -> Foreign) (J.stringify x)

headers :: Maybe RequestBody.RequestBody -> Array RequestHeader
headers reqContent =
Expand Down

0 comments on commit d5a7a9c

Please sign in to comment.