-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancements to typed arrays #39
base: master
Are you sure you want to change the base?
Conversation
- the hs$export function had parameters fp2a fp2b but attempted to read fp1c and fp1d, which did not exist. - Export.hs assumed deref was called hs$derefExportedValue but the actual function is hs$derefValue. - A call to hs$retain was missing from the export.
Fix GHCJS.Foreign.Export
xhr must be opened before any modification, also add required exports
add h$isBoolean to jsbits. Req'd by GHCJS.Foreign
requestAnimationFrame provides its callback with a DOMHighResTimeStamp, measuring a monotonic clock time for each frame. I've extended the bindings such that waitForAnimationFrame and inAnimationFrame provide this value to the caller.
Add Performance.now and add time stamp information to requestAnimationFrame bindings
Seems like someone forgot to re-export Float32Array and Float64Array in JavaScript.TypedArray from JavaScript.TypedArray.Internal.Types. Also I would like to have (TypedArray a => JSRef -> a) interface for my WebGL things: some of the webGL methods return typed arrays of arbitrary type - https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView
Rename JSRef to JSVal
Added Float32/64 Typed array types
Thanks for this PR! I wanted to go over the typed array bindings once more before releasing improved-base, and this should be a good way to get the discussion started. It's rather big, so it may take me some time to digest it all. Can you give an example of how your code is more natural and flexible to use? Code that you couldn't have written before, or that can be written in a more general way now perhaps? In the end usability is what matters. Some general comments:
|
If you have time, hop on to |
First, on comments:
As for examples of usage:
|
…ynchronously, fix websocket, add bindings for Location object
simple FFI wrappers in the Canvas module
implement js_setLineDash and js_lineDashOffSet
As an example of code that can't be written. I can find no way to produce a |
I managed to merge my own typed arrays implementation into ghcjs-base one, trying to preserve your logic and structure. I do not really insist on merging this now, but rather want to invite you to discuss these changes.
Here are few things (that I remember now) about it:
IO
andST
operations from pure operations, such thatJavaScript.TypedArray.IO
andJavaScript.TypedArray.ST
are exactly the same, and any of these can be used together withJavaScript.TypedArray
equally. I think it is not a strong deviation from standard way of structuring Haskell modules, right?fromList :: [a] -> TypedArray a
andsetList :: Int -> [a] -> IOTypedArray a -> IO ()
thaw
/freeze
and conversions toByteArray
. This involves some trickery with type classes, but I hope this won't affect performance.Last thing: I think GHCJS.Buffer is a bit redundant. It looks like it is used only for conversions between JavaScript arrays/buffers and Haskell ByteArrays/Ptrs. Thus, maybe it is better to remove this module at all? Remaining conversion functions we can put into
GHCJS.Marshal
or somewhere else.In my version of typed arrays these conversions are done in
JavaScript.TypedArray
.