Skip to content

Commit 7f90bc4

Browse files
committed
arbitrary instance for AV
1 parent 525ca98 commit 7f90bc4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Data/ArrayBuffer/Typed/Unsafe.purs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import Data.ArrayBuffer.Types (ArrayView)
66
import Data.Maybe (Maybe(..))
77
import Data.Generic.Rep (class Generic)
88
import Effect.Unsafe (unsafePerformEffect)
9-
import Prelude (class Eq, class Monoid, class Ord, class Semigroup, class Show, bind, discard, pure, void, ($), (+), (<>))
9+
import Prelude (class Eq, class Monoid, class Ord, class Semigroup, class Show, bind, discard, pure, void, ($), (+), (<>), (<$>))
10+
import Test.QuickCheck (class Arbitrary, arbitrary)
1011

1112
newtype AV a t = AV (ArrayView a)
1213

@@ -33,3 +34,8 @@ instance semigroupArrayView :: TypedArray a t => Semigroup (AV a t) where
3334

3435
instance monoidArrayView :: TypedArray a t => Monoid (AV a t) where
3536
mempty = AV $ unsafePerformEffect $ TA.empty 0
37+
38+
instance arbitraryArrayView :: (TypedArray a t, Arbitrary t) => Arbitrary (AV a t) where
39+
arbitrary = do
40+
xs <- arbitrary
41+
pure $ unsafePerformEffect $ AV <$> TA.fromArray xs

0 commit comments

Comments
 (0)