Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Test.AtLeastTwoAndUnique (runAtLeastTwoAndUnique) where
- import Prelude
- import Data.Array (nub)
- import Test.StrongCheck (Arbitrary, arbitrary)
- import Test.StrongCheck.Gen (suchThat)
- import Data.Tuple (Tuple(..))
- import Data.Tuple.Nested (uncurry3)
- newtype AtLeastTwoAndUnique a = AtLeastTwoAndUnique (Tuple (Tuple a a) (Array a))
- runAtLeastTwoAndUnique :: forall a. AtLeastTwoAndUnique a -> { fst :: a, snd :: a, xs :: Array a }
- runAtLeastTwoAndUnique (AtLeastTwoAndUnique tuple) = (uncurry3 { fst: _, snd: _, xs: _ }) tuple
- instance arbAtLeastTwoAndUnique :: (Arbitrary a, Ord a, Show a) => Arbitrary (AtLeastTwoAndUnique a) where
- arbitrary = AtLeastTwoAndUnique `map` (arbitrary `suchThat` (unique `compose` toArray))
- where
- unique xs = nub xs `eq` xs
- toArray (Tuple (Tuple x1 x2) xs) = x1 : x2 : xs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement