Skip to content

Commit 0adc84d

Browse files
committed
avoiding sized-vector dependency
1 parent 9682a25 commit 0adc84d

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

bower.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"purescript-nullable": "^4.1.1",
2020
"purescript-typelevel": "^6.0.0",
2121
"purescript-uint": "^5.1.1",
22-
"purescript-sized-vectors": "git://github.com/athanclark/purescript-sized-vectors.git#4fcf13f5ed949e95242b99bcace1648e29bbcbad",
2322
"purescript-partial": "^2.0.1",
2423
"purescript-float32": "~0.1.1"
2524
},

src/Data/ArrayBuffer/DataView/Gen.purs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Data.ArrayBuffer.DataView.Gen where
22

3-
import Prelude ((<$>), bind, ($), (<=), (-), pure)
3+
import Prelude ((<$>), bind, (<=), (-), pure)
44

55
import Control.Monad.Gen (suchThat)
66
import Control.Monad.Gen.Class (class MonadGen, chooseInt)
@@ -9,12 +9,8 @@ import Data.ArrayBuffer.ArrayBuffer.Gen (genArrayBuffer)
99
import Data.ArrayBuffer.DataView (whole, byteLength)
1010
import Data.ArrayBuffer.Types (DataView, ByteOffset, kind ArrayViewType)
1111
import Data.ArrayBuffer.ValueMapping (class BytesPerValue, class BinaryValue)
12-
import Data.Maybe (Maybe(Just))
1312
import Data.Typelevel.Num (class Nat, toInt')
1413
import Data.Unfoldable (replicateA)
15-
import Data.Vec (Vec)
16-
import Data.Vec (fromArray) as Vec
17-
import Partial.Unsafe (unsafePartial)
1814
import Type.Proxy (Proxy(..))
1915

2016

@@ -27,7 +23,7 @@ genDataView = whole <$> genArrayBuffer
2723

2824
-- | For generating some set of offsets residing inside the generated array, with some computable value
2925
data WithOffsetAndValue n (a :: ArrayViewType) t =
30-
WithOffsetAndValue (Vec n ByteOffset) t DataView
26+
WithOffsetAndValue (Array ByteOffset) t DataView
3127

3228
genWithOffsetAndValue :: forall m n a b t
3329
. MonadGen m
@@ -44,8 +40,6 @@ genWithOffsetAndValue gen genT = do
4440
b = toInt' (Proxy :: Proxy b)
4541
xs <- gen `suchThat` \xs -> b <= byteLength xs
4642
let l = byteLength xs
47-
mos <- replicateA n (chooseInt 0 (l - b))
48-
let os = unsafePartial $ case Vec.fromArray mos of
49-
Just q -> q
43+
os <- replicateA n (chooseInt 0 (l - b))
5044
t <- genT
5145
pure (WithOffsetAndValue os t xs)

src/Data/ArrayBuffer/Typed/Gen.purs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,19 @@
22

33
module Data.ArrayBuffer.Typed.Gen where
44

5+
import Prelude ((<$>), bind, (/), (-), negate, ($), bottom, pure, top)
56
import Control.Monad.Gen.Class (class MonadGen, sized, chooseInt, chooseFloat)
67
import Data.ArrayBuffer.Typed (class TypedArray)
78
import Data.ArrayBuffer.Typed as TA
89
import Data.ArrayBuffer.Types (ArrayView)
910
import Data.Float32 (Float32, fromNumber') as F
1011
import Data.Generic.Rep (class Generic)
11-
import Data.Maybe (Maybe(..))
1212
import Data.Typelevel.Num (class Nat, toInt')
1313
import Data.UInt (UInt)
1414
import Data.UInt (fromInt) as UInt
1515
import Data.UInt.Gen (genUInt) as UInt
1616
import Data.Unfoldable (replicateA)
17-
import Data.Vec (Vec)
18-
import Data.Vec (fromArray) as Vec
1917
import Effect.Unsafe (unsafePerformEffect)
20-
import Partial.Unsafe (unsafePartial)
21-
import Prelude ((<$>), bind, (/), (-), negate, ($), bottom, pure, top)
2218
import 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)
6258
derive instance genericWithIndices :: Generic (ArrayView a) a' => Generic (WithIndices n a) _
6359

6460
genWithIndices :: 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

Comments
 (0)