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

Some kind of mind-map of the existing types on GHCJS, and how to convert to/from JS? #51

Open VictorTaelin opened 8 years ago

VictorTaelin commented 8 years ago

I'm trying to convert Haskell's Data.Vector.Unboxed.Vector Word32 to JavaScript's Uint32Array. I'm sure there is probably some short, one-line, perhaps even O(1) way to do it. The problem is finding it. Browsing through GHCJS's source code, I find a ton of different possibly related types:

SomeBuffer, SomeArrayBuffer, I.SomeInt32Array, ByteArray#, Buffer, ByteString, 
JSArray, MutableArrayBuffer, ArrayBuffer, STArrayBuffer, SomeSTTypedArray, 
SomeUint32Array, IOUint32Array, Uint32Array (...)

And that's not even 10% of the thing. I have an impression it is very well organized, and most of those types are probably necessary and I see a very clear relationship between them, JS arrays, and JS TypedArrays. Yet, the whole is still huge and it is not clear enough what each thing is for. Some kind of mind-map (even if in a written form), connecting all those pieces together, would come very hand for me and anyone else trying to understand GHCJS's source code. Is anyone willing to do the dirty job?