22
33module Data.ArrayBuffer.Typed.Gen where
44
5+ import Prelude ((<$>), bind , (/), (-), negate , ($), bottom , pure , top )
56import Control.Monad.Gen.Class (class MonadGen , sized , chooseInt , chooseFloat )
67import Data.ArrayBuffer.Typed (class TypedArray )
78import Data.ArrayBuffer.Typed as TA
89import Data.ArrayBuffer.Types (ArrayView )
910import Data.Float32 (Float32 , fromNumber' ) as F
1011import Data.Generic.Rep (class Generic )
11- import Data.Maybe (Maybe (..))
1212import Data.Typelevel.Num (class Nat , toInt' )
1313import Data.UInt (UInt )
1414import Data.UInt (fromInt ) as UInt
1515import Data.UInt.Gen (genUInt ) as UInt
1616import Data.Unfoldable (replicateA )
17- import Data.Vec (Vec )
18- import Data.Vec (fromArray ) as Vec
1917import Effect.Unsafe (unsafePerformEffect )
20- import Partial.Unsafe (unsafePartial )
21- import Prelude ((<$>), bind , (/), (-), negate , ($), bottom , pure , top )
2218import Type.Proxy (Proxy (..))
2319
2420
@@ -58,7 +54,7 @@ genFloat64 = chooseFloat ((-1.7976931348623157e+308)/div) (1.7976931348623157e+3
5854 where div = 4.0
5955
6056-- | For generating some set of offsets residing inside the generated array
61- data WithIndices n a = WithIndices (Vec n TA.Index ) (ArrayView a )
57+ data WithIndices n a = WithIndices (Array TA.Index ) (ArrayView a )
6258derive instance genericWithIndices :: Generic (ArrayView a ) a' => Generic (WithIndices n a ) _
6359
6460genWithIndices :: forall m n a
@@ -70,7 +66,5 @@ genWithIndices gen = do
7066 let n = toInt' (Proxy :: Proxy n )
7167 xs <- gen
7268 let l = TA .length xs
73- mos <- replicateA n (chooseInt 0 (l - 1 ))
74- let os = unsafePartial $ case Vec .fromArray mos of
75- Just q -> q
69+ os <- replicateA n (chooseInt 0 (l - 1 ))
7670 pure (WithIndices os xs)
0 commit comments