Skip to content

Commit 9802a96

Browse files
committed
Ensure usages of unsafeToForeign are typed
1 parent ec9c50e commit 9802a96

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/Affjax.purs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import Data.Argonaut.Core (Json)
3030
import Data.Argonaut.Core as J
3131
import Data.Argonaut.Parser (jsonParser)
3232
import Data.Array as Arr
33+
import Data.ArrayBuffer.Types (ArrayView)
3334
import Data.Either (Either(..), either)
3435
import Data.Foldable (any)
3536
import Data.FormURLEncoded as FormURLEncoded
@@ -49,6 +50,9 @@ import Effect.Exception (Error, error)
4950
import Effect.Ref as Ref
5051
import Foreign (F, Foreign, ForeignError(..), fail, unsafeReadTagged, unsafeToForeign)
5152
import Math as Math
53+
import Web.DOM (Document)
54+
import Web.File.Blob (Blob)
55+
import Web.XHR.FormData (FormData)
5256

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

267271
extractContent :: RequestBody.RequestBody -> Foreign
268272
extractContent = case _ of
269-
RequestBody.ArrayView f → f unsafeToForeign
270-
RequestBody.Blob x → unsafeToForeign x
271-
RequestBody.Document x → unsafeToForeign x
272-
RequestBody.String x → unsafeToForeign x
273-
RequestBody.FormData x → unsafeToForeign x
274-
RequestBody.FormURLEncoded x → unsafeToForeign (FormURLEncoded.encode x)
275-
RequestBody.Json x → unsafeToForeign (J.stringify x)
273+
RequestBody.ArrayView f → f (unsafeToForeign :: forall a. ArrayView a -> Foreign)
274+
RequestBody.Blob x → (unsafeToForeign :: Blob -> Foreign) x
275+
RequestBody.Document x → (unsafeToForeign :: Document -> Foreign) x
276+
RequestBody.String x → (unsafeToForeign :: String -> Foreign) x
277+
RequestBody.FormData x → (unsafeToForeign :: FormData -> Foreign) x
278+
RequestBody.FormURLEncoded x → (unsafeToForeign :: String -> Foreign) (FormURLEncoded.encode x)
279+
RequestBody.Json x → (unsafeToForeign :: String -> Foreign) (J.stringify x)
276280

277281
headers :: Maybe RequestBody.RequestBody -> Array RequestHeader
278282
headers reqContent =

0 commit comments

Comments
 (0)