Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cannot set TypedArrayData in XMLHttpRequest.RequestData #58

Open
ElvishJerricco opened this issue Mar 14, 2016 · 4 comments
Open

Cannot set TypedArrayData in XMLHttpRequest.RequestData #58

ElvishJerricco opened this issue Mar 14, 2016 · 4 comments

Comments

@ElvishJerricco
Copy link

This code:

import           JavaScript.TypedArray
import qualified JavaScript.Web.XMLHttpRequest as XHR

setData :: Uint8Array -> XHR.Request -> XHR.Request
setData u8 req = req { XHR.reqData = XHR.TypedArrayData u8 }

Produces this error message:

Couldn't match kind ‘AnyK’ with ‘*’
Expected type: ghcjs-base-0.2.0.0:JavaScript.TypedArray.Internal.Types.SomeTypedArray
                 e 'ghcjs-base-0.2.0.0:GHCJS.Internal.Types.Immutable
  Actual type: Uint8Array
In the first argument of ‘XHR.TypedArrayData’, namely ‘u8’
In the ‘XHR.reqData’ field of a record

As far as I can tell, this is the intended purpose of XHR.TypedArrayData, so I'm not sure why it doesn't work.

@iand675
Copy link

iand675 commented Jul 13, 2016

I'm seeing the same issue. @mgsloan any ideas?

@mgsloan
Copy link
Contributor

mgsloan commented Jul 19, 2016

Hmm, I'm not sure what's going wrong there. One possible hack would be to coerce u8, should be representationally equivalent.

@iand675
Copy link

iand675 commented Jul 20, 2016

Yeah, I ended up slapping an unsafeCoerce on to get around it shortly after commenting on the issue, but there's definitely a bit of an impedance mismatch at the type level that appears to make XHR.TypedArrayData not usable without coercion.

@mikelpr
Copy link
Contributor

mikelpr commented May 15, 2019

got bit by this today

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants