1 {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, TypeSynonymInstances, UndecidableInstances #-}
7 import qualified Data

.Vector

as DV

8 import qualified Data

.Vector

.IVector

as DVI

9 import qualified Data

.Vector

.Unboxed

as DVU

10 import qualified Data

.Vector

.Unboxed

.Unbox

as DVUU

11 import qualified Data

.Vector

.Fusion

.Stream

as S

14 instance Show a

=> Show (S

.Stream a

) where
15 show s

= "Data.Vector.Fusion.Stream.fromList " ++ show (S

.toList s

)
18 instance Arbitrary a

=> Arbitrary

(DV

.Vector a

) where
19 arbitrary

= fmap DV

.fromList arbitrary

20 coarbitrary

= coarbitrary

. DV

.toList

22 instance (Arbitrary a

, DVUU

.Unbox a

) => Arbitrary

(DVU

.Vector a

) where
23 arbitrary

= fmap DVU

.fromList arbitrary

24 coarbitrary

= coarbitrary

. DVU

.toList

26 instance Arbitrary a

=> Arbitrary

(S

.Stream a

) where
27 arbitrary

= fmap S

.fromList arbitrary

28 coarbitrary

= coarbitrary

. S

.toList

31 class Model a b | a

-> b

where
32 -- | Convert a concrete value into an abstract model
35 -- The meat of the models
36 instance Model

(DV

.Vector a

) [a

] where model

= DV

.toList

37 instance DVUU

.Unbox a

=> Model

(DVU

.Vector a

) [a

] where model

= DVU

.toList

40 instance Model

Bool Bool where model

= id
41 instance Model

Int Int where model

= id
42 instance Model

Ordering Ordering where model

= id
45 -- All of these need UndecidableInstances although they are actually well founded. Oh well.
46 instance Model a b

=> Model

(Maybe a

) (Maybe b

) where model

= fmap model

47 instance (Model a c

, Model b d

) => Model

(a

, b

) (c

, d

) where model

(a

, b

) = (model a

, model b

)
48 instance (Model c a

, Model b d

) => Model

(a

-> b

) (c

-> d

) where model f

= model

. f

. model

51 eq0 f g

= model f

== g

52 eq1 f g

= \a -> model

(f a

) == g

(model a

)
53 eq2 f g

= \a b

-> model

(f a b

) == g

(model a

) (model b

)
54 eq3 f g

= \a b c

-> model

(f a b c

) == g

(model a

) (model b

) (model c

)
56 eqNotNull1 f g

= \x

-> (not (DVI

.null x

)) ==> eq1 f g x

57 eqNotNull2 f g

= \x y

-> (not (DVI

.null y

)) ==> eq2 f g x y

58 eqNotNull3 f g

= \x y z

-> (not (DVI

.null z

)) ==> eq3 f g x y z