11module Data.ArrayBuffer.Typed
2- ( buffer
2+ ( polyFill
3+ , buffer
34 , byteOffset
45 , byteLength
6+ , AProxy (..)
57 , class Bytes
68 , bytesPer
79 , length
@@ -15,17 +17,20 @@ module Data.ArrayBuffer.Typed
1517
1618import Prelude
1719import Effect (Effect )
20+ import Effect.Uncurried (EffectFn2 , runEffectFn2 )
1821import Data.ArrayBuffer.Types
19- ( ArrayView , ByteOffset
22+ ( ArrayView , kind ArrayViewType , ArrayBuffer , ByteOffset , ByteLength
2023 , Float64Array , Float32Array
2124 , Uint8ClampedArray , Uint32Array , Uint16Array , Uint8Array , Int32Array , Int16Array , Int8Array
2225 , Float64 , Float32
2326 , Uint8Clamped , Uint32 , Uint16 , Uint8 , Int32 , Int16 , Int8 )
2427import Data.Function.Uncurried (Fn2 , Fn3 , runFn2 , runFn3 )
2528import Data.Maybe (Maybe (..))
26- import Type.Proxy (Proxy (..))
2729
2830
31+ -- | Lightweight polyfill for ie - see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Methods_Polyfill
32+ foreign import polyFill :: Effect Unit
33+
2934-- | `ArrayBuffer` being mapped by the typed array.
3035foreign import buffer :: forall a . ArrayView a -> ArrayBuffer
3136
@@ -37,23 +42,25 @@ foreign import byteLength :: forall a. ArrayView a -> ByteLength
3742
3843foreign import lengthImpl :: forall a . ArrayView a -> Int
3944
40- class Bytes a where
41- bytesPer :: Proxy a -> Int
45+ data AProxy (a :: ArrayViewType ) = AProxy
46+
47+ class Bytes (a :: ArrayViewType ) where
48+ bytesPer :: AProxy a -> Int
4249
4350instance bytesUint8Clamped :: Bytes Uint8Clamped where
44- bytesPer Proxy = 1
51+ bytesPer AProxy = 1
4552instance bytesUint32 :: Bytes Uint32 where
46- bytesPer Proxy = 4
53+ bytesPer AProxy = 4
4754instance bytesUint16 :: Bytes Uint16 where
48- bytesPer Proxy = 2
55+ bytesPer AProxy = 2
4956instance bytesUint8 :: Bytes Uint8 where
50- bytesPer Proxy = 1
57+ bytesPer AProxy = 1
5158instance bytesInt32 :: Bytes Int32 where
52- bytesPer Proxy = 4
59+ bytesPer AProxy = 4
5360instance bytesInt16 :: Bytes Int16 where
54- bytesPer Proxy = 2
61+ bytesPer AProxy = 2
5562instance bytesInt8 :: Bytes Int8 where
56- bytesPer Proxy = 1
63+ bytesPer AProxy = 1
5764
5865length :: forall a . Bytes a => ArrayView a -> Int
5966length = lengthImpl
0 commit comments