-
Notifications
You must be signed in to change notification settings - Fork 22
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
How to create Arrays? #2
Comments
This is an area that probably needs some work. We have some modules in JSaddle that try to provide the same interface as
|
It also seems we need to add |
So far I've come to this:
I'm still trying to figure out how to cast |
Okay, so I simply stuck |
I think that the way to do this may be through the |
@hamishmack Is the casting something which is likely to be fixed at some point, or will coercions be here to stay? |
Apologies if this isn't quite the right place for this but, this is how I currently create a new "typed" array via jsaddle-dom (using ghcjs-dom): toFloat32Array :: MonadJSM m => [Double] -> m Float32Array
toFloat32Array ds = liftJSM $ do
a <- new (jsg ("Float32Array" :: Text)) [ds]
unsafeCastTo Float32Array a This feels pretty horrid to me but thus far it works. I've a function for 'Uint8Array' that works the same way. I'll be trying to add a fix for the |
I am also stuck here, while trying to port this file from using just |
I have never solved this without coercion, but I also haven't worked on it in a long time. |
This hack seems to work for me :-(
|
I see there are many types of arrays (
Float32Array
,ArrayBuffer
,Int32Array
, ...), and many type classes that these array objects belong to (IsFloat32Array
,IsGObject
,IsJSVal
,PToJSVal
, ...) but it isn't immediately clear how to construct one of these arrays (perhaps with 1, 2, 3, etc, values) without using FFI - which seems to break the goal of jsaddle. Any tips?The text was updated successfully, but these errors were encountered: