@@ -7,6 +7,7 @@
77{-# LANGUAGE OverloadedStrings #-}
88{-# LANGUAGE RecordWildCards #-}
99{-# LANGUAGE ScopedTypeVariables #-}
10+{-# LANGUAGE TemplateHaskell #-}
1011{-# LANGUAGE TypeOperators #-}
1112{-# OPTIONS_GHC -fno-warn-orphans #-}
1213#if __GLASGOW_HASKELL__ < 800
@@ -24,6 +25,7 @@ import Control.Monad
2425import Control.Monad.Catch
2526import Control.Monad.Reader
2627import Data.Aeson
28+import Data.Aeson.TH
2729import Data.Aeson.Types (parseEither)
2830import qualified Data.ByteString.Lazy.Char8 as BL8
2931import qualified Data.HashMap.Strict as HM
@@ -44,7 +46,6 @@ import Data.Typeable
4446import qualified Data.Vector as V
4547import qualified Data.Version as Vers
4648import Database.V5.Bloodhound
47−-- import GHC.Generics as G
4849import Network.HTTP.Client hiding (Proxy)
4950import qualified Network.HTTP.Types.Method as NHTM
5051import qualified Network.HTTP.Types.Status as NHTS
@@ -57,9 +58,8 @@ import Test.QuickCheck.Property.Monoid (T (..), eq, prop_Monoid)
5758
5859import Test.Hspec.QuickCheck (prop)
5960import Test.QuickCheck
60−
61−import qualified Generics.SOP as SOP
62−import qualified Generics.SOP.GGP as SOP
61+import Test.QuickCheck.TH.Generators
62+import Text.Pretty.Simple (pPrint)
6363
6464testServer :: Server
6565testServer = Server "http://localhost:9200"
@@ -153,13 +153,19 @@ is v = getServerVersion >>= \x -> return $ x == Just v
153153when' :: Monad m => m Bool -> m () -> m ()
154154when' b f = b >>= \x -> when x f
155155
156−(==~) :: (ApproxEq a) => a -> a -> Property
157−a ==~ b = counterexample (showApproxEq a ++ " !=~ " ++ showApproxEq b) (a =~ b)
158−
159−propJSON :: forall a. (Arbitrary a, ToJSON a, FromJSON a, Show a, ApproxEq a, Typeable a) => Proxy a -> Spec
156+propJSON :: forall a
157+ . ( Arbitrary a
158+ , ToJSON a
159+ , FromJSON a
160+ , Show a
161+ , Eq a
162+ , Typeable a
163+ )
164+ => Proxy a -> Spec
160165propJSON _ = prop testName $ \(a :: a) ->
161166 let jsonStr = "via " <> BL8.unpack (encode a)
162− in counterexample jsonStr (parseEither parseJSON (toJSON a) ==~ Right a)
167+ in counterexample jsonStr (parseEither parseJSON (toJSON a)
168+ === Right a)
163169 where testName = show ty <> " FromJSON/ToJSON roundtrips"
164170 ty = typeOf (undefined :: a)
165171
@@ -174,14 +180,8 @@ data Tweet = Tweet { user :: Text
174180 , extra :: Maybe Text }
175181 deriving (Eq, Show)
176182
177−instance ToJSON Tweet where
178− toJSON = genericToJSON defaultOptions
179−instance FromJSON Tweet where
180− parseJSON = genericParseJSON defaultOptions
181−instance ToJSON Location where
182− toJSON = genericToJSON defaultOptions
183−instance FromJSON Location where
184− parseJSON = genericParseJSON defaultOptions
183+$(deriveJSON defaultOptions ''Location)
184+$(deriveJSON defaultOptions ''Tweet)
185185
186186data ParentMapping = ParentMapping deriving (Eq, Show)
187187
@@ -433,208 +433,63 @@ withSnapshot srn sn = bracket_ alloc free
433433
434434
435435
436−data BulkTest = BulkTest { name :: Text } deriving (Eq, Show)
437−instance FromJSON BulkTest where
438− parseJSON = genericParseJSON defaultOptions
439−instance ToJSON BulkTest where
440− toJSON = genericToJSON defaultOptions
441−
442−class GApproxEq f where
443− gApproxEq :: f a -> f a -> Bool
444−
445−-- | Unit type
446−instance GApproxEq U1 where
447− gApproxEq U1 U1 = True
448−
449−-- | Sum type, ensure same constructors, recurse
450−instance (GApproxEq a, GApproxEq b) => GApproxEq (a :+: b) where
451− gApproxEq (L1 a) (L1 b) = gApproxEq a b
452− gApproxEq (R1 a) (R1 b) = gApproxEq a b
453− gApproxEq _ _ = False
454−
455−-- | Product type, ensure each field is approx eq
456−instance (GApproxEq a, GApproxEq b) => GApproxEq (a :*: b) where
457− gApproxEq (a1 :*: b1) (a2 :*: b2) = gApproxEq a1 a2 && gApproxEq b1 b2
458−
459−-- | Value type, actually check the values for approx equality
460−instance (ApproxEq a) => GApproxEq (K1 i a) where
461− gApproxEq (K1 a) (K1 b) = a =~ b
462−
463−instance (GApproxEq f) => GApproxEq (M1 i t f) where
464− gApproxEq (M1 a) (M1 b) = gApproxEq a b
436+newtype BulkTest =
437+ BulkTest { name :: Text }
438+ deriving (Eq, Show, FromJSON, ToJSON)
465439
466440-- | Typeclass for "equal where it matters". Use this to specify
467441-- less-strict equivalence for things such as lists that can wind up
468442-- in an unpredictable order
469443class ApproxEq a where
470444 (=~) :: a -> a -> Bool
471− default (=~) :: (Generic a, GApproxEq (Rep a)) => a -> a -> Bool
472− a =~ b = gApproxEq (G.from a) (G.from b)
473445
474446 showApproxEq :: a -> String
475447 default showApproxEq :: (Show a) => a -> String
476448 showApproxEq = show
477449
450+(==~) :: (ApproxEq a) => a -> a -> Property
451+a ==~ b = counterexample (showApproxEq a ++ " !=~ " ++ showApproxEq b) (a =~ b)
452+
453+propApproxJSON :: forall a
454+ . ( Arbitrary a
455+ , ToJSON a
456+ , FromJSON a
457+ , Show a
458+ , ApproxEq a
459+ , Typeable a
460+ )
461+ => Proxy a -> Spec
462+propApproxJSON _ = prop testName $ \(a :: a) ->
463+ let jsonStr = "via " <> BL8.unpack (encode a)
464+ in counterexample jsonStr (parseEither parseJSON (toJSON a)
465+ ==~ Right a)
466+ where testName = show ty <> " FromJSON/ToJSON roundtrips"
467+ ty = typeOf (undefined :: a)
468+
478469instance ApproxEq NominalDiffTime where (=~) = (==)
479−instance ApproxEq UTCTime where (=~) = (==)
480−instance ApproxEq Text where (=~) = (==)
481470instance ApproxEq Bool where (=~) = (==)
482471instance ApproxEq Int where (=~) = (==)
483−instance ApproxEq Double where (=~) = (==)
484−instance (ApproxEq a, Show a) => ApproxEq (NonEmpty a)
485−instance (ApproxEq a, Show a) => ApproxEq (Maybe a)
486−instance ApproxEq GeoPoint
487−instance ApproxEq Regexp
488−instance ApproxEq RangeValue
489−instance ApproxEq LessThan
490−instance ApproxEq LessThanEq
491−instance ApproxEq LessThanD
492−instance ApproxEq LessThanEqD
493−instance ApproxEq GreaterThan
494−instance ApproxEq GreaterThanEq
495−instance ApproxEq GreaterThanD
496−instance ApproxEq GreaterThanEqD
497−instance ApproxEq MinimumMatchHighLow
498−instance ApproxEq RegexpFlag
499−instance ApproxEq RegexpFlags
500−instance ApproxEq NullValue
501−instance ApproxEq Version
502−instance ApproxEq VersionNumber
503−instance ApproxEq DistanceRange
504−instance ApproxEq IndexName
505−instance ApproxEq MappingName
506−instance ApproxEq DocId
507−instance ApproxEq IndexAliasRouting
508−instance ApproxEq RoutingValue
509−instance ApproxEq ShardCount
510−instance ApproxEq ReplicaCount
511−instance ApproxEq TemplateName
512−instance ApproxEq TemplatePattern
513−instance ApproxEq QueryString
514−instance ApproxEq FieldName
515−instance ApproxEq CacheName
516−instance ApproxEq CacheKey
517−instance ApproxEq Existence
518−instance ApproxEq CutoffFrequency
519−instance ApproxEq Analyzer
520−instance ApproxEq Lenient
521−instance ApproxEq Tiebreaker
522−instance ApproxEq Boost
523−instance ApproxEq BoostTerms
524−instance ApproxEq MaxExpansions
525−instance ApproxEq MinimumMatch
526−instance ApproxEq DisableCoord
527−instance ApproxEq IgnoreTermFrequency
528−instance ApproxEq MinimumTermFrequency
529−instance ApproxEq MaxQueryTerms
530−instance ApproxEq Fuzziness
531−instance ApproxEq PrefixLength
532−instance ApproxEq TypeName
533−instance ApproxEq PercentMatch
534−instance ApproxEq StopWord
535−instance ApproxEq QueryPath
536−instance ApproxEq AllowLeadingWildcard
537−instance ApproxEq LowercaseExpanded
538−instance ApproxEq EnablePositionIncrements
539−instance ApproxEq AnalyzeWildcard
540−instance ApproxEq GeneratePhraseQueries
541−instance ApproxEq Locale
542−instance ApproxEq MaxWordLength
543−instance ApproxEq MinWordLength
544−instance ApproxEq PhraseSlop
545−instance ApproxEq MinDocFrequency
546−instance ApproxEq MaxDocFrequency
547−instance ApproxEq Filter
548−instance ApproxEq Query
549−instance ApproxEq SimpleQueryStringQuery
550−instance ApproxEq FieldOrFields
551−instance ApproxEq SimpleQueryFlag
552−instance ApproxEq RegexpQuery
553−instance ApproxEq QueryStringQuery
554−instance ApproxEq RangeQuery
555−instance ApproxEq PrefixQuery
556−instance ApproxEq NestedQuery
557−instance ApproxEq MoreLikeThisFieldQuery
558−instance ApproxEq MoreLikeThisQuery
559−instance ApproxEq IndicesQuery
560−instance ApproxEq HasParentQuery
561−instance ApproxEq HasChildQuery
562−instance ApproxEq FuzzyQuery
563−instance ApproxEq FuzzyLikeFieldQuery
564−instance ApproxEq FuzzyLikeThisQuery
565−instance ApproxEq DisMaxQuery
566−instance ApproxEq CommonTermsQuery
567−instance ApproxEq CommonMinimumMatch
568−instance ApproxEq BoostingQuery
569−instance ApproxEq BoolQuery
570−instance ApproxEq MatchQuery
571−instance ApproxEq MultiMatchQueryType
572−instance ApproxEq BooleanOperator
573−instance ApproxEq ZeroTermsQuery
574−instance ApproxEq MatchQueryType
575−instance ApproxEq AliasRouting
576−instance ApproxEq IndexAliasCreate
577−instance ApproxEq SearchAliasRouting
578−instance ApproxEq ScoreType
579−instance ApproxEq Distance
580−instance ApproxEq DistanceUnit
581−instance ApproxEq DistanceType
582−instance ApproxEq OptimizeBbox
583−instance ApproxEq GeoBoundingBoxConstraint
584−instance ApproxEq GeoFilterType
585−instance ApproxEq GeoBoundingBox
586−instance ApproxEq LatLon
587−instance ApproxEq RangeExecution
588−instance ApproxEq FSType
589−instance ApproxEq CompoundFormat
590−instance ApproxEq InitialShardCount
591−instance ApproxEq Bytes
592−instance ApproxEq ReplicaBounds
593−instance ApproxEq Term
594−instance ApproxEq BoolMatch
595−instance ApproxEq MultiMatchQuery
596−instance ApproxEq IndexSettings
597−instance ApproxEq AllocationPolicy
472+instance (Eq a, Show a) => ApproxEq (Maybe a) where (=~) = (==)
598473instance ApproxEq Char where
599474 (=~) = (==)
600−instance ApproxEq Vers.Version where
601− (=~) = (==)
602−instance (ApproxEq a, Show a) => ApproxEq [a] where
603− as =~ bs = and (zipWith (=~) as bs)
475+
476+instance ApproxEq NodeAttrFilter where (=~) = (==)
477+instance ApproxEq NodeAttrName where (=~) = (==)
478+instance (Eq a, Show a) => ApproxEq (NonEmpty a) where (=~) = (==)
604479instance (ApproxEq l, Show l, ApproxEq r, Show r) => ApproxEq (Either l r) where
605480 Left a =~ Left b = a =~ b
606481 Right a =~ Right b = a =~ b
607482 _ =~ _ = False
608483 showApproxEq (Left x) = "Left " <> showApproxEq x
609484 showApproxEq (Right x) = "Right " <> showApproxEq x
610−instance ApproxEq NodeAttrFilter
611−instance ApproxEq NodeAttrName
612−instance ApproxEq BuildHash
613−instance ApproxEq TemplateQueryKeyValuePairs where
614− (=~) = (==)
615−instance ApproxEq TemplateQueryInline
616−instance ApproxEq Size
617−instance ApproxEq PhraseSuggesterHighlighter
618−instance ApproxEq PhraseSuggesterCollate
619−instance ApproxEq PhraseSuggester
620−instance ApproxEq SuggestType
621−instance ApproxEq Suggest
622−
623−-- | Due to the way nodeattrfilters get serialized here, they may come
624−-- out in a different order, but they are morally equivalent
625−instance ApproxEq UpdatableIndexSetting where
626− RoutingAllocationInclude a =~ RoutingAllocationInclude b =
627− NE.sort a =~ NE.sort b
628− RoutingAllocationExclude a =~ RoutingAllocationExclude b =
629− NE.sort a =~ NE.sort b
630− RoutingAllocationRequire a =~ RoutingAllocationRequire b =
631− NE.sort a =~ NE.sort b
632− a =~ b = a == b
633− showApproxEq (RoutingAllocationInclude xs) = show (RoutingAllocationInclude (NE.sort xs))
634− showApproxEq (RoutingAllocationExclude xs) = show (RoutingAllocationExclude (NE.sort xs))
635− showApproxEq (RoutingAllocationRequire xs) = show (RoutingAllocationRequire (NE.sort xs))
636− showApproxEq x = show x
637−
485+instance (ApproxEq a, Show a) => ApproxEq [a] where
486+ as =~ bs = and (zipWith (=~) as bs)
487+instance ApproxEq ReplicaCount where (=~) = (==)
488+instance ApproxEq ReplicaBounds where (=~) = (==)
489+instance ApproxEq Bytes where (=~) = (==)
490+instance ApproxEq AllocationPolicy where (=~) = (==)
491+instance ApproxEq InitialShardCount where (=~) = (==)
492+instance ApproxEq FSType where (=~) = (==)
638493
639494noDuplicates :: Eq a => [a] -> Bool
640495noDuplicates xs = nub xs == xs
@@ -674,7 +529,7 @@ instance (Arbitrary a, Typeable a) => Arbitrary (Hit a) where
674529 <*> arbitraryScore
675530 <*> arbitrary
676531 <*> arbitrary
677− shrink = genericShrink
532+
678533
679534
680535instance (Arbitrary a, Typeable a) => Arbitrary (SearchHits a) where
@@ -683,7 +538,7 @@ instance (Arbitrary a, Typeable a) => Arbitrary (SearchHits a) where
683538 score <- arbitraryScore
684539 hs <- arbitrary
685540 return $ SearchHits tot score hs
686− shrink = genericShrink
541+
687542
688543reduceSize :: Gen a -> Gen a
689544reduceSize f = sized $ \n -> resize (n `div` 2) f
@@ -721,12 +576,14 @@ instance Arbitrary AliasRouting where
721576 <$> (Just <$> arbitrary)
722577 <*> (Just <$> arbitrary)
723578 allAlias = AllAliasRouting <$> arbitrary
724− shrink = genericShrink
579+
725580
726581
727582instance Arbitrary FieldName where
728− arbitrary = FieldName . T.pack <$> listOf1 arbitraryAlphaNum
729− shrink = genericShrink
583+ arbitrary =
584+ FieldName
585+ . T.pack
586+ <$> listOf1 arbitraryAlphaNum
730587
731588
732589#if MIN_VERSION_base(4,10,0)
@@ -737,7 +594,9 @@ qcNonEmptyToNonEmpty (NonEmpty (a : xs)) = (a :| xs)
737594qcNonEmptyToNonEmpty (NonEmpty []) = error "NonEmpty was empty!"
738595
739596instance Arbitrary a => Arbitrary (NonEmpty a) where
740− arbitrary = qcNonEmptyToNonEmpty <$> arbitrary
597+ arbitrary =
598+ qcNonEmptyToNonEmpty
599+ <$> arbitrary
741600#endif
742601
743602instance Arbitrary RegexpFlags where
@@ -745,62 +604,73 @@ instance Arbitrary RegexpFlags where
745604 , pure NoRegexpFlags
746605 , SomeRegexpFlags <$> genUniqueFlags
747606 ]
748− where genUniqueFlags = NE.fromList . nub <$> listOf1 arbitrary
749−
750− shrink = genericShrink
751−
607+ where genUniqueFlags =
608+ NE.fromList . nub
609+ <$> listOf1 arbitrary
752610
753611instance Arbitrary IndexAliasCreate where
754− arbitrary = IndexAliasCreate <$> arbitrary <*> reduceSize arbitrary
755− shrink = genericShrink
612+ arbitrary =
613+ IndexAliasCreate
614+ <$> arbitrary
615+ <*> reduceSize arbitrary
756616
757617instance Arbitrary Query where
758− arbitrary = reduceSize $ oneof [ TermQuery <$> arbitrary <*> arbitrary
759− , TermsQuery <$> arbitrary <*> arbitrary
760− , QueryMatchQuery <$> arbitrary
761− , QueryMultiMatchQuery <$> arbitrary
762− , QueryBoolQuery <$> arbitrary
763− , QueryBoostingQuery <$> arbitrary
764− , QueryCommonTermsQuery <$> arbitrary
765− , ConstantScoreQuery <$> arbitrary <*> arbitrary
766− , QueryDisMaxQuery <$> arbitrary
767− , QueryFuzzyLikeThisQuery <$> arbitrary
768− , QueryFuzzyLikeFieldQuery <$> arbitrary
769− , QueryFuzzyQuery <$> arbitrary
770− , QueryHasChildQuery <$> arbitrary
771− , QueryHasParentQuery <$> arbitrary
772− , IdsQuery <$> arbitrary <*> arbitrary
773− , QueryIndicesQuery <$> arbitrary
774− , MatchAllQuery <$> arbitrary
775− , QueryMoreLikeThisQuery <$> arbitrary
776− , QueryMoreLikeThisFieldQuery <$> arbitrary
777− , QueryNestedQuery <$> arbitrary
778− , QueryPrefixQuery <$> arbitrary
779− , QueryQueryStringQuery <$> arbitrary
780− , QuerySimpleQueryStringQuery <$> arbitrary
781− , QueryRangeQuery <$> arbitrary
782− , QueryRegexpQuery <$> arbitrary
783− , QueryTemplateQueryInline <$> arbitrary
784− ]
785− shrink = genericShrink
618+ arbitrary =
619+ reduceSize
620+ $ oneof [ TermQuery <$> arbitrary <*> arbitrary
621+ , TermsQuery <$> arbitrary <*> arbitrary
622+ , QueryMatchQuery <$> arbitrary
623+ , QueryMultiMatchQuery <$> arbitrary
624+ , QueryBoolQuery <$> arbitrary
625+ , QueryBoostingQuery <$> arbitrary
626+ , QueryCommonTermsQuery <$> arbitrary
627+ , ConstantScoreQuery <$> arbitrary <*> arbitrary
628+ , QueryDisMaxQuery <$> arbitrary
629+ , QueryFuzzyLikeThisQuery <$> arbitrary
630+ , QueryFuzzyLikeFieldQuery <$> arbitrary
631+ , QueryFuzzyQuery <$> arbitrary
632+ , QueryHasChildQuery <$> arbitrary
633+ , QueryHasParentQuery <$> arbitrary
634+ , IdsQuery <$> arbitrary <*> arbitrary
635+ , QueryIndicesQuery <$> arbitrary
636+ , MatchAllQuery <$> arbitrary
637+ , QueryMoreLikeThisQuery <$> arbitrary
638+ , QueryMoreLikeThisFieldQuery <$> arbitrary
639+ , QueryNestedQuery <$> arbitrary
640+ , QueryPrefixQuery <$> arbitrary
641+ , QueryQueryStringQuery <$> arbitrary
642+ , QuerySimpleQueryStringQuery <$> arbitrary
643+ , QueryRangeQuery <$> arbitrary
644+ , QueryRegexpQuery <$> arbitrary
645+ , QueryTemplateQueryInline <$> arbitrary
646+ ]
647+ -- TODO: Implement shrink
648+ -- shrink = genericShrink
786649
787650instance Arbitrary Filter where
788− arbitrary = Filter <$> arbitrary
789− shrink = genericShrink
651+ arbitrary =
652+ Filter <$> arbitrary
653+ shrink (Filter q) =
654+ Filter <$> shrink q
790655
791656instance Arbitrary ReplicaBounds where
792657 arbitrary = oneof [ replicasBounded
793658 , replicasLowerBounded
794659 , pure ReplicasUnbounded
795660 ]
796− where replicasBounded = do Positive a <- arbitrary
797− Positive b <- arbitrary
798− return (ReplicasBounded a b)
799− replicasLowerBounded = do Positive a <- arbitrary
800− return (ReplicasLowerBounded a)
661+ where replicasBounded = do
662+ Positive a <- arbitrary
663+ Positive b <- arbitrary
664+ return (ReplicasBounded a b)
665+ replicasLowerBounded = do
666+ Positive a <- arbitrary
667+ return (ReplicasLowerBounded a)
801668
802669instance Arbitrary NodeAttrName where
803− arbitrary = NodeAttrName . T.pack <$> listOf1 arbitraryAlphaNum
670+ arbitrary =
671+ NodeAttrName
672+ . T.pack
673+ <$> listOf1 arbitraryAlphaNum
804674
805675
806676instance Arbitrary NodeAttrFilter where
@@ -809,7 +679,6 @@ instance Arbitrary NodeAttrFilter where
809679 s:ss <- listOf1 (listOf1 arbitraryAlphaNum)
810680 let ts = T.pack <$> s :| ss
811681 return (NodeAttrFilter n ts)
812− shrink = genericShrink
813682
814683instance Arbitrary VersionNumber where
815684 arbitrary = mk . fmap getPositive . getNonEmpty <$> arbitrary
@@ -820,142 +689,285 @@ instance Arbitrary TemplateQueryKeyValuePairs where
820689 arbitrary = TemplateQueryKeyValuePairs . HM.fromList <$> arbitrary
821690 shrink (TemplateQueryKeyValuePairs x) = map (TemplateQueryKeyValuePairs . HM.fromList) . shrink $ HM.toList x
822691
823−instance Arbitrary IndexName where arbitrary = sopArbitrary; shrink = genericShrink
824−instance Arbitrary MappingName where arbitrary = sopArbitrary; shrink = genericShrink
825−instance Arbitrary DocId where arbitrary = sopArbitrary; shrink = genericShrink
826−instance Arbitrary Version where arbitrary = sopArbitrary; shrink = genericShrink
827−instance Arbitrary BuildHash where arbitrary = sopArbitrary; shrink = genericShrink
828−instance Arbitrary IndexAliasRouting where arbitrary = sopArbitrary; shrink = genericShrink
829−instance Arbitrary ShardCount where arbitrary = sopArbitrary; shrink = genericShrink
830−instance Arbitrary ReplicaCount where arbitrary = sopArbitrary; shrink = genericShrink
831−instance Arbitrary TemplateName where arbitrary = sopArbitrary; shrink = genericShrink
832−instance Arbitrary TemplatePattern where arbitrary = sopArbitrary; shrink = genericShrink
833−instance Arbitrary QueryString where arbitrary = sopArbitrary; shrink = genericShrink
834−instance Arbitrary CacheName where arbitrary = sopArbitrary; shrink = genericShrink
835−instance Arbitrary CacheKey where arbitrary = sopArbitrary; shrink = genericShrink
836−instance Arbitrary Existence where arbitrary = sopArbitrary; shrink = genericShrink
837−instance Arbitrary CutoffFrequency where arbitrary = sopArbitrary; shrink = genericShrink
838−instance Arbitrary Analyzer where arbitrary = sopArbitrary; shrink = genericShrink
839−instance Arbitrary MaxExpansions where arbitrary = sopArbitrary; shrink = genericShrink
840−instance Arbitrary Lenient where arbitrary = sopArbitrary; shrink = genericShrink
841−instance Arbitrary Tiebreaker where arbitrary = sopArbitrary; shrink = genericShrink
842−instance Arbitrary Boost where arbitrary = sopArbitrary; shrink = genericShrink
843−instance Arbitrary BoostTerms where arbitrary = sopArbitrary; shrink = genericShrink
844−instance Arbitrary MinimumMatch where arbitrary = sopArbitrary; shrink = genericShrink
845−instance Arbitrary DisableCoord where arbitrary = sopArbitrary; shrink = genericShrink
846−instance Arbitrary IgnoreTermFrequency where arbitrary = sopArbitrary; shrink = genericShrink
847−instance Arbitrary MinimumTermFrequency where arbitrary = sopArbitrary; shrink = genericShrink
848−instance Arbitrary MaxQueryTerms where arbitrary = sopArbitrary; shrink = genericShrink
849−instance Arbitrary Fuzziness where arbitrary = sopArbitrary; shrink = genericShrink
850−instance Arbitrary PrefixLength where arbitrary = sopArbitrary; shrink = genericShrink
851−instance Arbitrary TypeName where arbitrary = sopArbitrary; shrink = genericShrink
852−instance Arbitrary PercentMatch where arbitrary = sopArbitrary; shrink = genericShrink
853−instance Arbitrary StopWord where arbitrary = sopArbitrary; shrink = genericShrink
854−instance Arbitrary QueryPath where arbitrary = sopArbitrary; shrink = genericShrink
855−instance Arbitrary AllowLeadingWildcard where arbitrary = sopArbitrary; shrink = genericShrink
856−instance Arbitrary LowercaseExpanded where arbitrary = sopArbitrary; shrink = genericShrink
857−instance Arbitrary EnablePositionIncrements where arbitrary = sopArbitrary; shrink = genericShrink
858−instance Arbitrary AnalyzeWildcard where arbitrary = sopArbitrary; shrink = genericShrink
859−instance Arbitrary GeneratePhraseQueries where arbitrary = sopArbitrary; shrink = genericShrink
860−instance Arbitrary Locale where arbitrary = sopArbitrary; shrink = genericShrink
861−instance Arbitrary MaxWordLength where arbitrary = sopArbitrary; shrink = genericShrink
862−instance Arbitrary MinWordLength where arbitrary = sopArbitrary; shrink = genericShrink
863−instance Arbitrary PhraseSlop where arbitrary = sopArbitrary; shrink = genericShrink
864−instance Arbitrary MinDocFrequency where arbitrary = sopArbitrary; shrink = genericShrink
865−instance Arbitrary MaxDocFrequency where arbitrary = sopArbitrary; shrink = genericShrink
866−instance Arbitrary Regexp where arbitrary = sopArbitrary; shrink = genericShrink
867−instance Arbitrary SimpleQueryStringQuery where arbitrary = sopArbitrary; shrink = genericShrink
868−instance Arbitrary FieldOrFields where arbitrary = sopArbitrary; shrink = genericShrink
869−instance Arbitrary SimpleQueryFlag where arbitrary = sopArbitrary; shrink = genericShrink
870−instance Arbitrary RegexpQuery where arbitrary = sopArbitrary; shrink = genericShrink
871−instance Arbitrary QueryStringQuery where arbitrary = sopArbitrary; shrink = genericShrink
872−instance Arbitrary RangeQuery where arbitrary = sopArbitrary; shrink = genericShrink
873−instance Arbitrary RangeValue where arbitrary = sopArbitrary; shrink = genericShrink
874−instance Arbitrary PrefixQuery where arbitrary = sopArbitrary; shrink = genericShrink
875−instance Arbitrary NestedQuery where arbitrary = sopArbitrary; shrink = genericShrink
876−instance Arbitrary MoreLikeThisFieldQuery where arbitrary = sopArbitrary; shrink = genericShrink
877−instance Arbitrary MoreLikeThisQuery where arbitrary = sopArbitrary; shrink = genericShrink
878−instance Arbitrary IndicesQuery where arbitrary = sopArbitrary; shrink = genericShrink
879−instance Arbitrary HasParentQuery where arbitrary = sopArbitrary; shrink = genericShrink
880−instance Arbitrary HasChildQuery where arbitrary = sopArbitrary; shrink = genericShrink
881−instance Arbitrary FuzzyQuery where arbitrary = sopArbitrary; shrink = genericShrink
882−instance Arbitrary FuzzyLikeFieldQuery where arbitrary = sopArbitrary; shrink = genericShrink
883−instance Arbitrary FuzzyLikeThisQuery where arbitrary = sopArbitrary; shrink = genericShrink
884−instance Arbitrary DisMaxQuery where arbitrary = sopArbitrary; shrink = genericShrink
885−instance Arbitrary CommonTermsQuery where arbitrary = sopArbitrary; shrink = genericShrink
886−instance Arbitrary DistanceRange where arbitrary = sopArbitrary; shrink = genericShrink
887−instance Arbitrary MultiMatchQuery where arbitrary = sopArbitrary; shrink = genericShrink
888−instance Arbitrary LessThanD where arbitrary = sopArbitrary; shrink = genericShrink
889−instance Arbitrary LessThanEqD where arbitrary = sopArbitrary; shrink = genericShrink
890−instance Arbitrary GreaterThanD where arbitrary = sopArbitrary; shrink = genericShrink
891−instance Arbitrary GreaterThanEqD where arbitrary = sopArbitrary; shrink = genericShrink
892−instance Arbitrary LessThan where arbitrary = sopArbitrary; shrink = genericShrink
893−instance Arbitrary LessThanEq where arbitrary = sopArbitrary; shrink = genericShrink
894−instance Arbitrary GreaterThan where arbitrary = sopArbitrary; shrink = genericShrink
895−instance Arbitrary GreaterThanEq where arbitrary = sopArbitrary; shrink = genericShrink
896−instance Arbitrary GeoPoint where arbitrary = sopArbitrary; shrink = genericShrink
897−instance Arbitrary NullValue where arbitrary = sopArbitrary; shrink = genericShrink
898−instance Arbitrary MinimumMatchHighLow where arbitrary = sopArbitrary; shrink = genericShrink
899−instance Arbitrary CommonMinimumMatch where arbitrary = sopArbitrary; shrink = genericShrink
900−instance Arbitrary BoostingQuery where arbitrary = sopArbitrary; shrink = genericShrink
901−instance Arbitrary BoolQuery where arbitrary = sopArbitrary; shrink = genericShrink
902−instance Arbitrary MatchQuery where arbitrary = sopArbitrary; shrink = genericShrink
903−instance Arbitrary MultiMatchQueryType where arbitrary = sopArbitrary; shrink = genericShrink
904−instance Arbitrary BooleanOperator where arbitrary = sopArbitrary; shrink = genericShrink
905−instance Arbitrary ZeroTermsQuery where arbitrary = sopArbitrary; shrink = genericShrink
906−instance Arbitrary MatchQueryType where arbitrary = sopArbitrary; shrink = genericShrink
907−instance Arbitrary SearchAliasRouting where arbitrary = sopArbitrary; shrink = genericShrink
908−instance Arbitrary ScoreType where arbitrary = sopArbitrary; shrink = genericShrink
909−instance Arbitrary Distance where arbitrary = sopArbitrary; shrink = genericShrink
910−instance Arbitrary DistanceUnit where arbitrary = sopArbitrary; shrink = genericShrink
911−instance Arbitrary DistanceType where arbitrary = sopArbitrary; shrink = genericShrink
912−instance Arbitrary OptimizeBbox where arbitrary = sopArbitrary; shrink = genericShrink
913−instance Arbitrary GeoBoundingBoxConstraint where arbitrary = sopArbitrary; shrink = genericShrink
914−instance Arbitrary GeoFilterType where arbitrary = sopArbitrary; shrink = genericShrink
915−instance Arbitrary GeoBoundingBox where arbitrary = sopArbitrary; shrink = genericShrink
916−instance Arbitrary LatLon where arbitrary = sopArbitrary; shrink = genericShrink
917−instance Arbitrary RangeExecution where arbitrary = sopArbitrary; shrink = genericShrink
918−instance Arbitrary RegexpFlag where arbitrary = sopArbitrary; shrink = genericShrink
919−instance Arbitrary BoolMatch where arbitrary = sopArbitrary; shrink = genericShrink
920−instance Arbitrary Term where arbitrary = sopArbitrary; shrink = genericShrink
921−instance Arbitrary IndexSettings where arbitrary = sopArbitrary; shrink = genericShrink
922−instance Arbitrary TokenChar where arbitrary = sopArbitrary; shrink = genericShrink
923−instance Arbitrary Ngram where arbitrary = sopArbitrary; shrink = genericShrink
924−instance Arbitrary TokenizerDefinition where arbitrary = sopArbitrary; shrink = genericShrink
925−instance Arbitrary AnalyzerDefinition where arbitrary = sopArbitrary; shrink = genericShrink
926−instance Arbitrary Analysis where arbitrary = sopArbitrary; shrink = genericShrink
927−instance Arbitrary Tokenizer where arbitrary = sopArbitrary; shrink = genericShrink
928−instance Arbitrary UpdatableIndexSetting where arbitrary = sopArbitrary; shrink = genericShrink
929−instance Arbitrary Compression where arbitrary = sopArbitrary; shrink = genericShrink
930−instance Arbitrary Bytes where arbitrary = sopArbitrary; shrink = genericShrink
931−instance Arbitrary AllocationPolicy where arbitrary = sopArbitrary; shrink = genericShrink
932−instance Arbitrary InitialShardCount where arbitrary = sopArbitrary; shrink = genericShrink
933−instance Arbitrary FSType where arbitrary = sopArbitrary; shrink = genericShrink
934−instance Arbitrary CompoundFormat where arbitrary = sopArbitrary; shrink = genericShrink
935−instance Arbitrary FsSnapshotRepo where arbitrary = sopArbitrary; shrink = genericShrink
936−instance Arbitrary SnapshotRepoName where arbitrary = sopArbitrary; shrink = genericShrink
937−instance Arbitrary TemplateQueryInline where arbitrary = sopArbitrary; shrink = genericShrink
938−instance Arbitrary PhraseSuggesterCollate where arbitrary = sopArbitrary; shrink = genericShrink
939−instance Arbitrary PhraseSuggesterHighlighter where arbitrary = sopArbitrary; shrink = genericShrink
940−instance Arbitrary Size where arbitrary = sopArbitrary; shrink = genericShrink
941−instance Arbitrary PhraseSuggester where arbitrary = sopArbitrary; shrink = genericShrink
942−instance Arbitrary SuggestType where arbitrary = sopArbitrary; shrink = genericShrink
943−instance Arbitrary Suggest where arbitrary = sopArbitrary; shrink = genericShrink
944−
945−newtype UpdatableIndexSetting' = UpdatableIndexSetting' UpdatableIndexSetting
946− deriving (Show, Eq, ToJSON, FromJSON, ApproxEq, Typeable)
692+makeArbitrary ''IndexName
693+instance Arbitrary IndexName where arbitrary = arbitraryIndexName
694+makeArbitrary ''MappingName
695+instance Arbitrary MappingName where arbitrary = arbitraryMappingName
696+makeArbitrary ''DocId
697+instance Arbitrary DocId where arbitrary = arbitraryDocId
698+makeArbitrary ''Version
699+instance Arbitrary Version where arbitrary = arbitraryVersion
700+makeArbitrary ''BuildHash
701+instance Arbitrary BuildHash where arbitrary = arbitraryBuildHash
702+makeArbitrary ''IndexAliasRouting
703+instance Arbitrary IndexAliasRouting where arbitrary = arbitraryIndexAliasRouting
704+makeArbitrary ''ShardCount
705+instance Arbitrary ShardCount where arbitrary = arbitraryShardCount
706+makeArbitrary ''ReplicaCount
707+instance Arbitrary ReplicaCount where arbitrary = arbitraryReplicaCount
708+makeArbitrary ''TemplateName
709+instance Arbitrary TemplateName where arbitrary = arbitraryTemplateName
710+makeArbitrary ''TemplatePattern
711+instance Arbitrary TemplatePattern where arbitrary = arbitraryTemplatePattern
712+makeArbitrary ''QueryString
713+instance Arbitrary QueryString where arbitrary = arbitraryQueryString
714+makeArbitrary ''CacheName
715+instance Arbitrary CacheName where arbitrary = arbitraryCacheName
716+makeArbitrary ''CacheKey
717+instance Arbitrary CacheKey where arbitrary = arbitraryCacheKey
718+makeArbitrary ''Existence
719+instance Arbitrary Existence where arbitrary = arbitraryExistence
720+makeArbitrary ''CutoffFrequency
721+instance Arbitrary CutoffFrequency where arbitrary = arbitraryCutoffFrequency
722+makeArbitrary ''Analyzer
723+instance Arbitrary Analyzer where arbitrary = arbitraryAnalyzer
724+makeArbitrary ''MaxExpansions
725+instance Arbitrary MaxExpansions where arbitrary = arbitraryMaxExpansions
726+makeArbitrary ''Lenient
727+instance Arbitrary Lenient where arbitrary = arbitraryLenient
728+makeArbitrary ''Tiebreaker
729+instance Arbitrary Tiebreaker where arbitrary = arbitraryTiebreaker
730+makeArbitrary ''Boost
731+instance Arbitrary Boost where arbitrary = arbitraryBoost
732+makeArbitrary ''BoostTerms
733+instance Arbitrary BoostTerms where arbitrary = arbitraryBoostTerms
734+makeArbitrary ''MinimumMatch
735+instance Arbitrary MinimumMatch where arbitrary = arbitraryMinimumMatch
736+makeArbitrary ''DisableCoord
737+instance Arbitrary DisableCoord where arbitrary = arbitraryDisableCoord
738+makeArbitrary ''IgnoreTermFrequency
739+instance Arbitrary IgnoreTermFrequency where arbitrary = arbitraryIgnoreTermFrequency
740+makeArbitrary ''MinimumTermFrequency
741+instance Arbitrary MinimumTermFrequency where arbitrary = arbitraryMinimumTermFrequency
742+makeArbitrary ''MaxQueryTerms
743+instance Arbitrary MaxQueryTerms where arbitrary = arbitraryMaxQueryTerms
744+makeArbitrary ''Fuzziness
745+instance Arbitrary Fuzziness where arbitrary = arbitraryFuzziness
746+makeArbitrary ''PrefixLength
747+instance Arbitrary PrefixLength where arbitrary = arbitraryPrefixLength
748+makeArbitrary ''TypeName
749+instance Arbitrary TypeName where arbitrary = arbitraryTypeName
750+makeArbitrary ''PercentMatch
751+instance Arbitrary PercentMatch where arbitrary = arbitraryPercentMatch
752+makeArbitrary ''StopWord
753+instance Arbitrary StopWord where arbitrary = arbitraryStopWord
754+makeArbitrary ''QueryPath
755+instance Arbitrary QueryPath where arbitrary = arbitraryQueryPath
756+makeArbitrary ''AllowLeadingWildcard
757+instance Arbitrary AllowLeadingWildcard where arbitrary = arbitraryAllowLeadingWildcard
758+makeArbitrary ''LowercaseExpanded
759+instance Arbitrary LowercaseExpanded where arbitrary = arbitraryLowercaseExpanded
760+makeArbitrary ''EnablePositionIncrements
761+instance Arbitrary EnablePositionIncrements where arbitrary = arbitraryEnablePositionIncrements
762+makeArbitrary ''AnalyzeWildcard
763+instance Arbitrary AnalyzeWildcard where arbitrary = arbitraryAnalyzeWildcard
764+makeArbitrary ''GeneratePhraseQueries
765+instance Arbitrary GeneratePhraseQueries where arbitrary = arbitraryGeneratePhraseQueries
766+makeArbitrary ''Locale
767+instance Arbitrary Locale where arbitrary = arbitraryLocale
768+makeArbitrary ''MaxWordLength
769+instance Arbitrary MaxWordLength where arbitrary = arbitraryMaxWordLength
770+makeArbitrary ''MinWordLength
771+instance Arbitrary MinWordLength where arbitrary = arbitraryMinWordLength
772+makeArbitrary ''PhraseSlop
773+instance Arbitrary PhraseSlop where arbitrary = arbitraryPhraseSlop
774+makeArbitrary ''MinDocFrequency
775+instance Arbitrary MinDocFrequency where arbitrary = arbitraryMinDocFrequency
776+makeArbitrary ''MaxDocFrequency
777+instance Arbitrary MaxDocFrequency where arbitrary = arbitraryMaxDocFrequency
778+makeArbitrary ''Regexp
779+instance Arbitrary Regexp where arbitrary = arbitraryRegexp
780+makeArbitrary ''SimpleQueryStringQuery
781+instance Arbitrary SimpleQueryStringQuery where arbitrary = arbitrarySimpleQueryStringQuery
782+makeArbitrary ''FieldOrFields
783+instance Arbitrary FieldOrFields where arbitrary = arbitraryFieldOrFields
784+makeArbitrary ''SimpleQueryFlag
785+instance Arbitrary SimpleQueryFlag where arbitrary = arbitrarySimpleQueryFlag
786+makeArbitrary ''RegexpQuery
787+instance Arbitrary RegexpQuery where arbitrary = arbitraryRegexpQuery
788+makeArbitrary ''QueryStringQuery
789+instance Arbitrary QueryStringQuery where arbitrary = arbitraryQueryStringQuery
790+makeArbitrary ''RangeQuery
791+instance Arbitrary RangeQuery where arbitrary = arbitraryRangeQuery
792+makeArbitrary ''RangeValue
793+instance Arbitrary RangeValue where arbitrary = arbitraryRangeValue
794+makeArbitrary ''PrefixQuery
795+instance Arbitrary PrefixQuery where arbitrary = arbitraryPrefixQuery
796+makeArbitrary ''NestedQuery
797+instance Arbitrary NestedQuery where arbitrary = arbitraryNestedQuery
798+makeArbitrary ''MoreLikeThisFieldQuery
799+instance Arbitrary MoreLikeThisFieldQuery where arbitrary = arbitraryMoreLikeThisFieldQuery
800+makeArbitrary ''MoreLikeThisQuery
801+instance Arbitrary MoreLikeThisQuery where arbitrary = arbitraryMoreLikeThisQuery
802+makeArbitrary ''IndicesQuery
803+instance Arbitrary IndicesQuery where arbitrary = arbitraryIndicesQuery
804+makeArbitrary ''HasParentQuery
805+instance Arbitrary HasParentQuery where arbitrary = arbitraryHasParentQuery
806+makeArbitrary ''HasChildQuery
807+instance Arbitrary HasChildQuery where arbitrary = arbitraryHasChildQuery
808+makeArbitrary ''FuzzyQuery
809+instance Arbitrary FuzzyQuery where arbitrary = arbitraryFuzzyQuery
810+makeArbitrary ''FuzzyLikeFieldQuery
811+instance Arbitrary FuzzyLikeFieldQuery where arbitrary = arbitraryFuzzyLikeFieldQuery
812+makeArbitrary ''FuzzyLikeThisQuery
813+instance Arbitrary FuzzyLikeThisQuery where arbitrary = arbitraryFuzzyLikeThisQuery
814+makeArbitrary ''DisMaxQuery
815+instance Arbitrary DisMaxQuery where arbitrary = arbitraryDisMaxQuery
816+makeArbitrary ''CommonTermsQuery
817+instance Arbitrary CommonTermsQuery where arbitrary = arbitraryCommonTermsQuery
818+makeArbitrary ''DistanceRange
819+instance Arbitrary DistanceRange where arbitrary = arbitraryDistanceRange
820+makeArbitrary ''MultiMatchQuery
821+instance Arbitrary MultiMatchQuery where arbitrary = arbitraryMultiMatchQuery
822+makeArbitrary ''LessThanD
823+instance Arbitrary LessThanD where arbitrary = arbitraryLessThanD
824+makeArbitrary ''LessThanEqD
825+instance Arbitrary LessThanEqD where arbitrary = arbitraryLessThanEqD
826+makeArbitrary ''GreaterThanD
827+instance Arbitrary GreaterThanD where arbitrary = arbitraryGreaterThanD
828+makeArbitrary ''GreaterThanEqD
829+instance Arbitrary GreaterThanEqD where arbitrary = arbitraryGreaterThanEqD
830+makeArbitrary ''LessThan
831+instance Arbitrary LessThan where arbitrary = arbitraryLessThan
832+makeArbitrary ''LessThanEq
833+instance Arbitrary LessThanEq where arbitrary = arbitraryLessThanEq
834+makeArbitrary ''GreaterThan
835+instance Arbitrary GreaterThan where arbitrary = arbitraryGreaterThan
836+makeArbitrary ''GreaterThanEq
837+instance Arbitrary GreaterThanEq where arbitrary = arbitraryGreaterThanEq
838+makeArbitrary ''GeoPoint
839+instance Arbitrary GeoPoint where arbitrary = arbitraryGeoPoint
840+makeArbitrary ''NullValue
841+instance Arbitrary NullValue where arbitrary = arbitraryNullValue
842+makeArbitrary ''MinimumMatchHighLow
843+instance Arbitrary MinimumMatchHighLow where arbitrary = arbitraryMinimumMatchHighLow
844+makeArbitrary ''CommonMinimumMatch
845+instance Arbitrary CommonMinimumMatch where arbitrary = arbitraryCommonMinimumMatch
846+makeArbitrary ''BoostingQuery
847+instance Arbitrary BoostingQuery where arbitrary = arbitraryBoostingQuery
848+makeArbitrary ''BoolQuery
849+instance Arbitrary BoolQuery where arbitrary = arbitraryBoolQuery
850+makeArbitrary ''MatchQuery
851+instance Arbitrary MatchQuery where arbitrary = arbitraryMatchQuery
852+makeArbitrary ''MultiMatchQueryType
853+instance Arbitrary MultiMatchQueryType where arbitrary = arbitraryMultiMatchQueryType
854+makeArbitrary ''BooleanOperator
855+instance Arbitrary BooleanOperator where arbitrary = arbitraryBooleanOperator
856+makeArbitrary ''ZeroTermsQuery
857+instance Arbitrary ZeroTermsQuery where arbitrary = arbitraryZeroTermsQuery
858+makeArbitrary ''MatchQueryType
859+instance Arbitrary MatchQueryType where arbitrary = arbitraryMatchQueryType
860+makeArbitrary ''SearchAliasRouting
861+instance Arbitrary SearchAliasRouting where arbitrary = arbitrarySearchAliasRouting
862+makeArbitrary ''ScoreType
863+instance Arbitrary ScoreType where arbitrary = arbitraryScoreType
864+makeArbitrary ''Distance
865+instance Arbitrary Distance where arbitrary = arbitraryDistance
866+makeArbitrary ''DistanceUnit
867+instance Arbitrary DistanceUnit where arbitrary = arbitraryDistanceUnit
868+makeArbitrary ''DistanceType
869+instance Arbitrary DistanceType where arbitrary = arbitraryDistanceType
870+makeArbitrary ''OptimizeBbox
871+instance Arbitrary OptimizeBbox where arbitrary = arbitraryOptimizeBbox
872+makeArbitrary ''GeoBoundingBoxConstraint
873+instance Arbitrary GeoBoundingBoxConstraint where arbitrary = arbitraryGeoBoundingBoxConstraint
874+makeArbitrary ''GeoFilterType
875+instance Arbitrary GeoFilterType where arbitrary = arbitraryGeoFilterType
876+makeArbitrary ''GeoBoundingBox
877+instance Arbitrary GeoBoundingBox where arbitrary = arbitraryGeoBoundingBox
878+makeArbitrary ''LatLon
879+instance Arbitrary LatLon where arbitrary = arbitraryLatLon
880+makeArbitrary ''RangeExecution
881+instance Arbitrary RangeExecution where arbitrary = arbitraryRangeExecution
882+makeArbitrary ''RegexpFlag
883+instance Arbitrary RegexpFlag where arbitrary = arbitraryRegexpFlag
884+makeArbitrary ''BoolMatch
885+instance Arbitrary BoolMatch where arbitrary = arbitraryBoolMatch
886+makeArbitrary ''Term
887+instance Arbitrary Term where arbitrary = arbitraryTerm
888+makeArbitrary ''IndexSettings
889+instance Arbitrary IndexSettings where arbitrary = arbitraryIndexSettings
890+makeArbitrary ''TokenChar
891+instance Arbitrary TokenChar where arbitrary = arbitraryTokenChar
892+makeArbitrary ''Ngram
893+instance Arbitrary Ngram where arbitrary = arbitraryNgram
894+makeArbitrary ''TokenizerDefinition
895+instance Arbitrary TokenizerDefinition where arbitrary = arbitraryTokenizerDefinition
896+makeArbitrary ''AnalyzerDefinition
897+instance Arbitrary AnalyzerDefinition where arbitrary = arbitraryAnalyzerDefinition
898+makeArbitrary ''Analysis
899+instance Arbitrary Analysis where arbitrary = arbitraryAnalysis
900+makeArbitrary ''Tokenizer
901+instance Arbitrary Tokenizer where arbitrary = arbitraryTokenizer
902+makeArbitrary ''UpdatableIndexSetting
903+instance Arbitrary UpdatableIndexSetting where
904+ arbitrary = arbitraryUpdatableIndexSetting
905+makeArbitrary ''Compression
906+instance Arbitrary Compression where arbitrary = arbitraryCompression
907+makeArbitrary ''Bytes
908+instance Arbitrary Bytes where arbitrary = arbitraryBytes
909+makeArbitrary ''AllocationPolicy
910+instance Arbitrary AllocationPolicy where arbitrary = arbitraryAllocationPolicy
911+makeArbitrary ''InitialShardCount
912+instance Arbitrary InitialShardCount where arbitrary = arbitraryInitialShardCount
913+makeArbitrary ''FSType
914+instance Arbitrary FSType where arbitrary = arbitraryFSType
915+makeArbitrary ''CompoundFormat
916+instance Arbitrary CompoundFormat where arbitrary = arbitraryCompoundFormat
917+makeArbitrary ''FsSnapshotRepo
918+instance Arbitrary FsSnapshotRepo where arbitrary = arbitraryFsSnapshotRepo
919+makeArbitrary ''SnapshotRepoName
920+instance Arbitrary SnapshotRepoName where arbitrary = arbitrarySnapshotRepoName
921+makeArbitrary ''TemplateQueryInline
922+instance Arbitrary TemplateQueryInline where arbitrary = arbitraryTemplateQueryInline
923+makeArbitrary ''PhraseSuggesterCollate
924+instance Arbitrary PhraseSuggesterCollate where arbitrary = arbitraryPhraseSuggesterCollate
925+makeArbitrary ''PhraseSuggesterHighlighter
926+instance Arbitrary PhraseSuggesterHighlighter where arbitrary = arbitraryPhraseSuggesterHighlighter
927+makeArbitrary ''Size
928+instance Arbitrary Size where arbitrary = arbitrarySize
929+makeArbitrary ''PhraseSuggester
930+instance Arbitrary PhraseSuggester where arbitrary = arbitraryPhraseSuggester
931+makeArbitrary ''SuggestType
932+instance Arbitrary SuggestType where arbitrary = arbitrarySuggestType
933+makeArbitrary ''Suggest
934+instance Arbitrary Suggest where arbitrary = arbitrarySuggest
935+
936+newtype UpdatableIndexSetting' =
937+ UpdatableIndexSetting' UpdatableIndexSetting
938+ deriving (Show, Eq, ToJSON, FromJSON, ApproxEq, Typeable)
947939
948940instance Arbitrary UpdatableIndexSetting' where
949941 arbitrary = do
950942 settings <- arbitrary
951943 return $ UpdatableIndexSetting' $ case settings of
952− RoutingAllocationInclude xs -> RoutingAllocationInclude (dropDuplicateAttrNames xs)
953− RoutingAllocationExclude xs -> RoutingAllocationExclude (dropDuplicateAttrNames xs)
954− RoutingAllocationRequire xs -> RoutingAllocationRequire (dropDuplicateAttrNames xs)
944+ RoutingAllocationInclude xs ->
945+ RoutingAllocationInclude (dropDuplicateAttrNames xs)
946+ RoutingAllocationExclude xs ->
947+ RoutingAllocationExclude (dropDuplicateAttrNames xs)
948+ RoutingAllocationRequire xs ->
949+ RoutingAllocationRequire (dropDuplicateAttrNames xs)
955950 x -> x
956951 where
957− dropDuplicateAttrNames = NE.fromList . L.nubBy sameAttrName . NE.toList
958− sameAttrName a b = nodeAttrFilterName a == nodeAttrFilterName b
952+ dropDuplicateAttrNames =
953+ NE.fromList . L.nubBy sameAttrName . NE.toList
954+ sameAttrName a b =
955+ nodeAttrFilterName a == nodeAttrFilterName b
956+
957+-- | Due to the way nodeattrfilters get serialized here, they may come
958+-- out in a different order, but they are morally equivalent
959+instance ApproxEq UpdatableIndexSetting where
960+ RoutingAllocationInclude a =~ RoutingAllocationInclude b =
961+ NE.sort a =~ NE.sort b
962+ RoutingAllocationExclude a =~ RoutingAllocationExclude b =
963+ NE.sort a =~ NE.sort b
964+ RoutingAllocationRequire a =~ RoutingAllocationRequire b =
965+ NE.sort a =~ NE.sort b
966+ a =~ b = a == b
967+ showApproxEq (RoutingAllocationInclude xs) = show (RoutingAllocationInclude (NE.sort xs))
968+ showApproxEq (RoutingAllocationExclude xs) = show (RoutingAllocationExclude (NE.sort xs))
969+ showApproxEq (RoutingAllocationRequire xs) = show (RoutingAllocationRequire (NE.sort xs))
970+ showApproxEq x = show x
959971
960972main :: IO ()
961973main = hspec $ do
@@ -1055,14 +1067,26 @@ main = hspec $ do
10551067 let thirdDoc = BulkCreateEncoding testIndex
10561068 testMapping (DocId "4") (toEncoding thirdTest)
10571069 let stream = V.fromList [firstDoc, secondDoc, thirdDoc]
1058− _ <- bulk stream
1059− _ <- refreshIndex testIndex
1070+ bulkResp <- bulk stream
1071+ liftIO $ pPrint bulkResp
1072+ refreshResp <- refreshIndex testIndex
1073+ liftIO $ pPrint refreshResp
10601074 fDoc <- getDocument testIndex testMapping (DocId "2")
10611075 sDoc <- getDocument testIndex testMapping (DocId "3")
10621076 tDoc <- getDocument testIndex testMapping (DocId "4")
1063− let maybeFirst = eitherDecode $ responseBody fDoc :: Either String (EsResult BulkTest)
1064− let maybeSecond = eitherDecode $ responseBody sDoc :: Either String (EsResult BulkTest)
1065− let maybeThird = eitherDecode $ responseBody tDoc :: Either String (EsResult BulkTest)
1077+ let maybeFirst =
1078+ eitherDecode
1079+ $ responseBody fDoc
1080+ :: Either String (EsResult BulkTest)
1081+ let maybeSecond =
1082+ eitherDecode
1083+ $ responseBody sDoc
1084+ :: Either String (EsResult BulkTest)
1085+ let maybeThird =
1086+ eitherDecode
1087+ $ responseBody tDoc
1088+ :: Either String (EsResult BulkTest)
1089+ liftIO $ pPrint [maybeFirst, maybeSecond, maybeThird]
10661090 liftIO $ do
10671091 fmap getSource maybeFirst `shouldBe` Right (Just firstTest)
10681092 fmap getSource maybeSecond `shouldBe` Right (Just secondTest)
@@ -1602,10 +1626,14 @@ main = hspec $ do
16021626 liftIO $ validateStatus resp 200
16031627 deleteIndexAlias aname
16041628 getIndexAliases
1605− let expected = IndexAliasSummary alias create
1629+ -- let expected = IndexAliasSummary alias create
16061630 case aliases of
16071631 Right (IndexAliasesSummary summs) ->
1608− L.find ((== aname) . indexAlias . indexAliasSummaryAlias) summs `shouldBe` Nothing
1632+ L.find ( (== aname)
1633+ . indexAlias
1634+ . indexAliasSummaryAlias
1635+ ) summs
1636+ `shouldBe` Nothing
16091637 Left e -> expectationFailure ("Expected an IndexAliasesSummary but got " <> show e)
16101638
16111639 describe "Index Listing" $ do
@@ -1701,7 +1729,7 @@ main = hspec $ do
17011729 Left e -> liftIO $ expectationFailure ("Expected an search suggestion but got " <> show e)
17021730 Right sr -> liftIO $ (suggestOptionsText . head . suggestResponseOptions . head . nsrResponses <$> suggest sr) `shouldBe` expectedText
17031731
1704− describe "JSON instances" $ do
1732+ describe "Exact isomorphism JSON instances" $ do
17051733 propJSON (Proxy :: Proxy Version)
17061734 propJSON (Proxy :: Proxy IndexName)
17071735 propJSON (Proxy :: Proxy MappingName)
@@ -1796,26 +1824,14 @@ main = hspec $ do
17961824 propJSON (Proxy :: Proxy Term)
17971825 propJSON (Proxy :: Proxy MultiMatchQuery)
17981826 propJSON (Proxy :: Proxy IndexSettings)
1799− propJSON (Proxy :: Proxy UpdatableIndexSetting')
1800− propJSON (Proxy :: Proxy ReplicaBounds)
1801− propJSON (Proxy :: Proxy Bytes)
1802− propJSON (Proxy :: Proxy AllocationPolicy)
1803− propJSON (Proxy :: Proxy InitialShardCount)
1804− propJSON (Proxy :: Proxy FSType)
18051827 propJSON (Proxy :: Proxy CompoundFormat)
18061828 propJSON (Proxy :: Proxy TemplateQueryInline)
18071829 propJSON (Proxy :: Proxy Suggest)
1808−
1809−-- Temporary solution for lacking of generic derivation of Arbitrary
1810−-- We use generics-sop, as it's much more concise than directly using GHC.Generics
1811−--
1812−-- This will be unneeded after https://github.com/nick8325/quickcheck/pull/112
1813−-- is merged and released
1814−sopArbitrary :: forall a. (Generic a, SOP.GTo a, SOP.All SOP.SListI (SOP.GCode a), SOP.All2 Arbitrary (SOP.GCode a)) => Gen a
1815−sopArbitrary = fmap SOP.gto sopArbitrary'
1816−
1817−sopArbitrary' :: forall xss. (SOP.All SOP.SListI xss, SOP.All2 Arbitrary xss) => Gen (SOP.SOP SOP.I xss)
1818−sopArbitrary' = SOP.hsequence =<< elements (SOP.apInjs_POP $ SOP.hcpure p arbitrary)
1819− where
1820− p :: Proxy Arbitrary
1821− p = Proxy
1830+ describe "Approximate isomorphism JSON instances" $ do
1831+ propApproxJSON (Proxy :: Proxy UpdatableIndexSetting')
1832+ propApproxJSON (Proxy :: Proxy ReplicaCount)
1833+ propApproxJSON (Proxy :: Proxy ReplicaBounds)
1834+ propApproxJSON (Proxy :: Proxy Bytes)
1835+ propApproxJSON (Proxy :: Proxy AllocationPolicy)
1836+ propApproxJSON (Proxy :: Proxy InitialShardCount)
1837+ propApproxJSON (Proxy :: Proxy FSType)