ghcjs / ghcjs-base

base library for GHCJS for JavaScript interaction and marshalling, used by higher level libraries like JSC
MIT License
45 stars 67 forks source link

Enhancements to typed arrays #39

Open achirkin opened 8 years ago

achirkin commented 8 years ago

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:

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.

luite commented 8 years ago

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:

luite commented 8 years ago

If you have time, hop on to #ghcjs on freenode for more discussion by the way. I'm not there all day (and I'm having a short break in Scotland later this week, so I'll be offline a bit more), but I do try to check in a few times each day.

achirkin commented 8 years ago

First, on comments:

As for examples of usage:

stepcut commented 6 years ago

As an example of code that can't be written. I can find no way to produce a Uint8ClampedArray value. I can produce a IOUint8ClampedArray value -- but there is no way to freeze it. And the JavaScript.TypedArray.ST module does not export the STTypedArray class -- so I can't create anUint8ClampedArray either.