git.iko.soy/typeable/bloodhound
on master help sign in
Merge pull request #155 from phadej/drop-derive
ef74b99Chris Allen
.travis.yml+2−2
@@ -16,13 +16,13 @@ env:
16 - GHCVER=7.10 ESVER=1.5.2
16 - GHCVER=7.10 ESVER=1.5.2
17 - GHCVER=7.10 ESVER=1.6.0
17 - GHCVER=7.10 ESVER=1.6.0
18 - GHCVER=7.10 ESVER=1.7.2
18 - GHCVER=7.10 ESVER=1.7.2
19+ - GHCVER=8.0 ESVER=1.7.2
19
20
20install:
21install:
21 # stack
22 # stack
22 - export STACK_YAML=stack-$GHCVER.yaml
23 - export STACK_YAML=stack-$GHCVER.yaml
23 - mkdir -p ~/.local/bin
24 - mkdir -p ~/.local/bin
24− - travis_retry curl -L https://github.com/commercialhaskell/stack/releases/download/v0.1.4.0/stack-0.1.4.0-x86_64-linux.tar.gz | tar -xvzf -
25+ - travis_retry curl -L https://github.com/commercialhaskell/stack/releases/download/v1.2.0/stack-1.2.0-linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
25− - mv stack ~/.local/bin
26 - export PATH=~/.local/bin:$PATH
26 - export PATH=~/.local/bin:$PATH
27 - stack --version
27 - stack --version
28
28
bloodhound.cabal+1−1
@@ -72,7 +72,7 @@ test-suite tests
72 unordered-containers >= 0.2.5.0 && <0.3,
72 unordered-containers >= 0.2.5.0 && <0.3,
73 mtl,
73 mtl,
74 quickcheck-properties,
74 quickcheck-properties,
75− derive,
75+ generics-sop >=0.2 && <0.3,
76 errors,
76 errors,
77 exceptions,
77 exceptions,
78 temporary,
78 temporary,
stack-7.8.yaml+1
@@ -15,4 +15,5 @@ extra-deps:
15- tagged-0.8.3
15- tagged-0.8.3
16- uri-bytestring-0.1.9
16- uri-bytestring-0.1.9
17- void-0.7.1
17- void-0.7.1
18+- generics-sop-0.2.2.0
18resolver: lts-2.18
19resolver: lts-2.18
tests/tests.hs+129−111
@@ -7,9 +7,11 @@
7{-# LANGUAGE OverloadedStrings #-}
7{-# LANGUAGE OverloadedStrings #-}
8{-# LANGUAGE RecordWildCards #-}
8{-# LANGUAGE RecordWildCards #-}
9{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE ScopedTypeVariables #-}
10−{-# LANGUAGE TemplateHaskell #-}
11{-# LANGUAGE TypeOperators #-}
10{-# LANGUAGE TypeOperators #-}
12{-# OPTIONS_GHC -fno-warn-orphans #-}
11{-# OPTIONS_GHC -fno-warn-orphans #-}
12+#if __GLASGOW_HASKELL__ < 800
13+{-# OPTIONS_GHC -fcontext-stack=100 #-}
14+#endif
13module Main where
15module Main where
14
16
15import Control.Applicative
17import Control.Applicative
@@ -21,7 +23,6 @@ import Control.Monad.Reader
21import Data.Aeson
23import Data.Aeson
22import Data.Aeson.Types (parseEither)
24import Data.Aeson.Types (parseEither)
23import qualified Data.ByteString.Lazy.Char8 as BL8
25import qualified Data.ByteString.Lazy.Char8 as BL8
24−import Data.DeriveTH
25import qualified Data.HashMap.Strict as HM
26import qualified Data.HashMap.Strict as HM
26import Data.List (nub)
27import Data.List (nub)
27import qualified Data.List as L
28import qualified Data.List as L
@@ -54,6 +55,8 @@ import Test.QuickCheck.Property.Monoid (T (..), eq, prop_Monoid)
54import Test.Hspec.QuickCheck (prop)
55import Test.Hspec.QuickCheck (prop)
55import Test.QuickCheck
56import Test.QuickCheck
56
57
58+import qualified Generics.SOP as SOP
59+import qualified Generics.SOP.GGP as SOP
57
60
58testServer :: Server
61testServer :: Server
59testServer = Server "http://localhost:9200"
62testServer = Server "http://localhost:9200"
@@ -577,7 +580,8 @@ instance ApproxEq BoolMatch
577instance ApproxEq MultiMatchQuery
580instance ApproxEq MultiMatchQuery
578instance ApproxEq IndexSettings
581instance ApproxEq IndexSettings
579instance ApproxEq AllocationPolicy
582instance ApproxEq AllocationPolicy
580−instance ApproxEq Char
583+instance ApproxEq Char where
584+ (=~) = (==)
581instance ApproxEq Vers.Version where
585instance ApproxEq Vers.Version where
582 (=~) = (==)
586 (=~) = (==)
583instance (ApproxEq a, Show a) => ApproxEq [a] where
587instance (ApproxEq a, Show a) => ApproxEq [a] where
@@ -794,114 +798,114 @@ instance Arbitrary VersionNumber where
794 where
798 where
795 mk versions = VersionNumber (Vers.Version versions [])
799 mk versions = VersionNumber (Vers.Version versions [])
796
800
797−$(derive makeArbitrary ''IndexName)
801+instance Arbitrary IndexName where arbitrary = sopArbitrary; shrink = genericShrink
798−$(derive makeArbitrary ''MappingName)
802+instance Arbitrary MappingName where arbitrary = sopArbitrary; shrink = genericShrink
799−$(derive makeArbitrary ''DocId)
803+instance Arbitrary DocId where arbitrary = sopArbitrary; shrink = genericShrink
800−$(derive makeArbitrary ''Version)
804+instance Arbitrary Version where arbitrary = sopArbitrary; shrink = genericShrink
801−$(derive makeArbitrary ''BuildHash)
805+instance Arbitrary BuildHash where arbitrary = sopArbitrary; shrink = genericShrink
802−$(derive makeArbitrary ''IndexAliasRouting)
806+instance Arbitrary IndexAliasRouting where arbitrary = sopArbitrary; shrink = genericShrink
803−$(derive makeArbitrary ''ShardCount)
807+instance Arbitrary ShardCount where arbitrary = sopArbitrary; shrink = genericShrink
804−$(derive makeArbitrary ''ReplicaCount)
808+instance Arbitrary ReplicaCount where arbitrary = sopArbitrary; shrink = genericShrink
805−$(derive makeArbitrary ''TemplateName)
809+instance Arbitrary TemplateName where arbitrary = sopArbitrary; shrink = genericShrink
806−$(derive makeArbitrary ''TemplatePattern)
810+instance Arbitrary TemplatePattern where arbitrary = sopArbitrary; shrink = genericShrink
807−$(derive makeArbitrary ''QueryString)
811+instance Arbitrary QueryString where arbitrary = sopArbitrary; shrink = genericShrink
808−$(derive makeArbitrary ''CacheName)
812+instance Arbitrary CacheName where arbitrary = sopArbitrary; shrink = genericShrink
809−$(derive makeArbitrary ''CacheKey)
813+instance Arbitrary CacheKey where arbitrary = sopArbitrary; shrink = genericShrink
810−$(derive makeArbitrary ''Existence)
814+instance Arbitrary Existence where arbitrary = sopArbitrary; shrink = genericShrink
811−$(derive makeArbitrary ''CutoffFrequency)
815+instance Arbitrary CutoffFrequency where arbitrary = sopArbitrary; shrink = genericShrink
812−$(derive makeArbitrary ''Analyzer)
816+instance Arbitrary Analyzer where arbitrary = sopArbitrary; shrink = genericShrink
813−$(derive makeArbitrary ''MaxExpansions)
817+instance Arbitrary MaxExpansions where arbitrary = sopArbitrary; shrink = genericShrink
814−$(derive makeArbitrary ''Lenient)
818+instance Arbitrary Lenient where arbitrary = sopArbitrary; shrink = genericShrink
815−$(derive makeArbitrary ''Tiebreaker)
819+instance Arbitrary Tiebreaker where arbitrary = sopArbitrary; shrink = genericShrink
816−$(derive makeArbitrary ''Boost)
820+instance Arbitrary Boost where arbitrary = sopArbitrary; shrink = genericShrink
817−$(derive makeArbitrary ''BoostTerms)
821+instance Arbitrary BoostTerms where arbitrary = sopArbitrary; shrink = genericShrink
818−$(derive makeArbitrary ''MinimumMatch)
822+instance Arbitrary MinimumMatch where arbitrary = sopArbitrary; shrink = genericShrink
819−$(derive makeArbitrary ''DisableCoord)
823+instance Arbitrary DisableCoord where arbitrary = sopArbitrary; shrink = genericShrink
820−$(derive makeArbitrary ''IgnoreTermFrequency)
824+instance Arbitrary IgnoreTermFrequency where arbitrary = sopArbitrary; shrink = genericShrink
821−$(derive makeArbitrary ''MinimumTermFrequency)
825+instance Arbitrary MinimumTermFrequency where arbitrary = sopArbitrary; shrink = genericShrink
822−$(derive makeArbitrary ''MaxQueryTerms)
826+instance Arbitrary MaxQueryTerms where arbitrary = sopArbitrary; shrink = genericShrink
823−$(derive makeArbitrary ''Fuzziness)
827+instance Arbitrary Fuzziness where arbitrary = sopArbitrary; shrink = genericShrink
824−$(derive makeArbitrary ''PrefixLength)
828+instance Arbitrary PrefixLength where arbitrary = sopArbitrary; shrink = genericShrink
825−$(derive makeArbitrary ''TypeName)
829+instance Arbitrary TypeName where arbitrary = sopArbitrary; shrink = genericShrink
826−$(derive makeArbitrary ''PercentMatch)
830+instance Arbitrary PercentMatch where arbitrary = sopArbitrary; shrink = genericShrink
827−$(derive makeArbitrary ''StopWord)
831+instance Arbitrary StopWord where arbitrary = sopArbitrary; shrink = genericShrink
828−$(derive makeArbitrary ''QueryPath)
832+instance Arbitrary QueryPath where arbitrary = sopArbitrary; shrink = genericShrink
829−$(derive makeArbitrary ''AllowLeadingWildcard)
833+instance Arbitrary AllowLeadingWildcard where arbitrary = sopArbitrary; shrink = genericShrink
830−$(derive makeArbitrary ''LowercaseExpanded)
834+instance Arbitrary LowercaseExpanded where arbitrary = sopArbitrary; shrink = genericShrink
831−$(derive makeArbitrary ''EnablePositionIncrements)
835+instance Arbitrary EnablePositionIncrements where arbitrary = sopArbitrary; shrink = genericShrink
832−$(derive makeArbitrary ''AnalyzeWildcard)
836+instance Arbitrary AnalyzeWildcard where arbitrary = sopArbitrary; shrink = genericShrink
833−$(derive makeArbitrary ''GeneratePhraseQueries)
837+instance Arbitrary GeneratePhraseQueries where arbitrary = sopArbitrary; shrink = genericShrink
834−$(derive makeArbitrary ''Locale)
838+instance Arbitrary Locale where arbitrary = sopArbitrary; shrink = genericShrink
835−$(derive makeArbitrary ''MaxWordLength)
839+instance Arbitrary MaxWordLength where arbitrary = sopArbitrary; shrink = genericShrink
836−$(derive makeArbitrary ''MinWordLength)
840+instance Arbitrary MinWordLength where arbitrary = sopArbitrary; shrink = genericShrink
837−$(derive makeArbitrary ''PhraseSlop)
841+instance Arbitrary PhraseSlop where arbitrary = sopArbitrary; shrink = genericShrink
838−$(derive makeArbitrary ''MinDocFrequency)
842+instance Arbitrary MinDocFrequency where arbitrary = sopArbitrary; shrink = genericShrink
839−$(derive makeArbitrary ''MaxDocFrequency)
843+instance Arbitrary MaxDocFrequency where arbitrary = sopArbitrary; shrink = genericShrink
840−$(derive makeArbitrary ''Regexp)
844+instance Arbitrary Regexp where arbitrary = sopArbitrary; shrink = genericShrink
841−$(derive makeArbitrary ''SimpleQueryStringQuery)
845+instance Arbitrary SimpleQueryStringQuery where arbitrary = sopArbitrary; shrink = genericShrink
842−$(derive makeArbitrary ''FieldOrFields)
846+instance Arbitrary FieldOrFields where arbitrary = sopArbitrary; shrink = genericShrink
843−$(derive makeArbitrary ''SimpleQueryFlag)
847+instance Arbitrary SimpleQueryFlag where arbitrary = sopArbitrary; shrink = genericShrink
844−$(derive makeArbitrary ''RegexpQuery)
848+instance Arbitrary RegexpQuery where arbitrary = sopArbitrary; shrink = genericShrink
845−$(derive makeArbitrary ''QueryStringQuery)
849+instance Arbitrary QueryStringQuery where arbitrary = sopArbitrary; shrink = genericShrink
846−$(derive makeArbitrary ''RangeQuery)
850+instance Arbitrary RangeQuery where arbitrary = sopArbitrary; shrink = genericShrink
847−$(derive makeArbitrary ''RangeValue)
851+instance Arbitrary RangeValue where arbitrary = sopArbitrary; shrink = genericShrink
848−$(derive makeArbitrary ''PrefixQuery)
852+instance Arbitrary PrefixQuery where arbitrary = sopArbitrary; shrink = genericShrink
849−$(derive makeArbitrary ''NestedQuery)
853+instance Arbitrary NestedQuery where arbitrary = sopArbitrary; shrink = genericShrink
850−$(derive makeArbitrary ''MoreLikeThisFieldQuery)
854+instance Arbitrary MoreLikeThisFieldQuery where arbitrary = sopArbitrary; shrink = genericShrink
851−$(derive makeArbitrary ''MoreLikeThisQuery)
855+instance Arbitrary MoreLikeThisQuery where arbitrary = sopArbitrary; shrink = genericShrink
852−$(derive makeArbitrary ''IndicesQuery)
856+instance Arbitrary IndicesQuery where arbitrary = sopArbitrary; shrink = genericShrink
853−$(derive makeArbitrary ''HasParentQuery)
857+instance Arbitrary HasParentQuery where arbitrary = sopArbitrary; shrink = genericShrink
854−$(derive makeArbitrary ''HasChildQuery)
858+instance Arbitrary HasChildQuery where arbitrary = sopArbitrary; shrink = genericShrink
855−$(derive makeArbitrary ''FuzzyQuery)
859+instance Arbitrary FuzzyQuery where arbitrary = sopArbitrary; shrink = genericShrink
856−$(derive makeArbitrary ''FuzzyLikeFieldQuery)
860+instance Arbitrary FuzzyLikeFieldQuery where arbitrary = sopArbitrary; shrink = genericShrink
857−$(derive makeArbitrary ''FuzzyLikeThisQuery)
861+instance Arbitrary FuzzyLikeThisQuery where arbitrary = sopArbitrary; shrink = genericShrink
858−$(derive makeArbitrary ''FilteredQuery)
862+instance Arbitrary FilteredQuery where arbitrary = sopArbitrary; shrink = genericShrink
859−$(derive makeArbitrary ''DisMaxQuery)
863+instance Arbitrary DisMaxQuery where arbitrary = sopArbitrary; shrink = genericShrink
860−$(derive makeArbitrary ''CommonTermsQuery)
864+instance Arbitrary CommonTermsQuery where arbitrary = sopArbitrary; shrink = genericShrink
861−$(derive makeArbitrary ''DistanceRange)
865+instance Arbitrary DistanceRange where arbitrary = sopArbitrary; shrink = genericShrink
862−$(derive makeArbitrary ''MultiMatchQuery)
866+instance Arbitrary MultiMatchQuery where arbitrary = sopArbitrary; shrink = genericShrink
863−$(derive makeArbitrary ''LessThanD)
867+instance Arbitrary LessThanD where arbitrary = sopArbitrary; shrink = genericShrink
864−$(derive makeArbitrary ''LessThanEqD)
868+instance Arbitrary LessThanEqD where arbitrary = sopArbitrary; shrink = genericShrink
865−$(derive makeArbitrary ''GreaterThanD)
869+instance Arbitrary GreaterThanD where arbitrary = sopArbitrary; shrink = genericShrink
866−$(derive makeArbitrary ''GreaterThanEqD)
870+instance Arbitrary GreaterThanEqD where arbitrary = sopArbitrary; shrink = genericShrink
867−$(derive makeArbitrary ''LessThan)
871+instance Arbitrary LessThan where arbitrary = sopArbitrary; shrink = genericShrink
868−$(derive makeArbitrary ''LessThanEq)
872+instance Arbitrary LessThanEq where arbitrary = sopArbitrary; shrink = genericShrink
869−$(derive makeArbitrary ''GreaterThan)
873+instance Arbitrary GreaterThan where arbitrary = sopArbitrary; shrink = genericShrink
870−$(derive makeArbitrary ''GreaterThanEq)
874+instance Arbitrary GreaterThanEq where arbitrary = sopArbitrary; shrink = genericShrink
871−$(derive makeArbitrary ''GeoPoint)
875+instance Arbitrary GeoPoint where arbitrary = sopArbitrary; shrink = genericShrink
872−$(derive makeArbitrary ''NullValue)
876+instance Arbitrary NullValue where arbitrary = sopArbitrary; shrink = genericShrink
873−$(derive makeArbitrary ''MinimumMatchHighLow)
877+instance Arbitrary MinimumMatchHighLow where arbitrary = sopArbitrary; shrink = genericShrink
874−$(derive makeArbitrary ''CommonMinimumMatch)
878+instance Arbitrary CommonMinimumMatch where arbitrary = sopArbitrary; shrink = genericShrink
875−$(derive makeArbitrary ''BoostingQuery)
879+instance Arbitrary BoostingQuery where arbitrary = sopArbitrary; shrink = genericShrink
876−$(derive makeArbitrary ''BoolQuery)
880+instance Arbitrary BoolQuery where arbitrary = sopArbitrary; shrink = genericShrink
877−$(derive makeArbitrary ''MatchQuery)
881+instance Arbitrary MatchQuery where arbitrary = sopArbitrary; shrink = genericShrink
878−$(derive makeArbitrary ''MultiMatchQueryType)
882+instance Arbitrary MultiMatchQueryType where arbitrary = sopArbitrary; shrink = genericShrink
879−$(derive makeArbitrary ''BooleanOperator)
883+instance Arbitrary BooleanOperator where arbitrary = sopArbitrary; shrink = genericShrink
880−$(derive makeArbitrary ''ZeroTermsQuery)
884+instance Arbitrary ZeroTermsQuery where arbitrary = sopArbitrary; shrink = genericShrink
881−$(derive makeArbitrary ''MatchQueryType)
885+instance Arbitrary MatchQueryType where arbitrary = sopArbitrary; shrink = genericShrink
882−$(derive makeArbitrary ''SearchAliasRouting)
886+instance Arbitrary SearchAliasRouting where arbitrary = sopArbitrary; shrink = genericShrink
883−$(derive makeArbitrary ''ScoreType)
887+instance Arbitrary ScoreType where arbitrary = sopArbitrary; shrink = genericShrink
884−$(derive makeArbitrary ''Distance)
888+instance Arbitrary Distance where arbitrary = sopArbitrary; shrink = genericShrink
885−$(derive makeArbitrary ''DistanceUnit)
889+instance Arbitrary DistanceUnit where arbitrary = sopArbitrary; shrink = genericShrink
886−$(derive makeArbitrary ''DistanceType)
890+instance Arbitrary DistanceType where arbitrary = sopArbitrary; shrink = genericShrink
887−$(derive makeArbitrary ''OptimizeBbox)
891+instance Arbitrary OptimizeBbox where arbitrary = sopArbitrary; shrink = genericShrink
888−$(derive makeArbitrary ''GeoBoundingBoxConstraint)
892+instance Arbitrary GeoBoundingBoxConstraint where arbitrary = sopArbitrary; shrink = genericShrink
889−$(derive makeArbitrary ''GeoFilterType)
893+instance Arbitrary GeoFilterType where arbitrary = sopArbitrary; shrink = genericShrink
890−$(derive makeArbitrary ''GeoBoundingBox)
894+instance Arbitrary GeoBoundingBox where arbitrary = sopArbitrary; shrink = genericShrink
891−$(derive makeArbitrary ''LatLon)
895+instance Arbitrary LatLon where arbitrary = sopArbitrary; shrink = genericShrink
892−$(derive makeArbitrary ''RangeExecution)
896+instance Arbitrary RangeExecution where arbitrary = sopArbitrary; shrink = genericShrink
893−$(derive makeArbitrary ''RegexpFlag)
897+instance Arbitrary RegexpFlag where arbitrary = sopArbitrary; shrink = genericShrink
894−$(derive makeArbitrary ''BoolMatch)
898+instance Arbitrary BoolMatch where arbitrary = sopArbitrary; shrink = genericShrink
895−$(derive makeArbitrary ''Term)
899+instance Arbitrary Term where arbitrary = sopArbitrary; shrink = genericShrink
896−$(derive makeArbitrary ''IndexSettings)
900+instance Arbitrary IndexSettings where arbitrary = sopArbitrary; shrink = genericShrink
897−$(derive makeArbitrary ''UpdatableIndexSetting)
901+instance Arbitrary UpdatableIndexSetting where arbitrary = sopArbitrary; shrink = genericShrink
898−$(derive makeArbitrary ''Bytes)
902+instance Arbitrary Bytes where arbitrary = sopArbitrary; shrink = genericShrink
899−$(derive makeArbitrary ''AllocationPolicy)
903+instance Arbitrary AllocationPolicy where arbitrary = sopArbitrary; shrink = genericShrink
900−$(derive makeArbitrary ''InitialShardCount)
904+instance Arbitrary InitialShardCount where arbitrary = sopArbitrary; shrink = genericShrink
901−$(derive makeArbitrary ''FSType)
905+instance Arbitrary FSType where arbitrary = sopArbitrary; shrink = genericShrink
902−$(derive makeArbitrary ''CompoundFormat)
906+instance Arbitrary CompoundFormat where arbitrary = sopArbitrary; shrink = genericShrink
903−$(derive makeArbitrary ''FsSnapshotRepo)
907+instance Arbitrary FsSnapshotRepo where arbitrary = sopArbitrary; shrink = genericShrink
904−$(derive makeArbitrary ''SnapshotRepoName)
908+instance Arbitrary SnapshotRepoName where arbitrary = sopArbitrary; shrink = genericShrink
905
909
906newtype UpdatableIndexSetting' = UpdatableIndexSetting' UpdatableIndexSetting
910newtype UpdatableIndexSetting' = UpdatableIndexSetting' UpdatableIndexSetting
907 deriving (Show, Eq, ToJSON, FromJSON, ApproxEq, Typeable)
911 deriving (Show, Eq, ToJSON, FromJSON, ApproxEq, Typeable)
@@ -1841,3 +1845,17 @@ main = hspec $ do
1841 propJSON (Proxy :: Proxy InitialShardCount)
1845 propJSON (Proxy :: Proxy InitialShardCount)
1842 propJSON (Proxy :: Proxy FSType)
1846 propJSON (Proxy :: Proxy FSType)
1843 propJSON (Proxy :: Proxy CompoundFormat)
1847 propJSON (Proxy :: Proxy CompoundFormat)
1848+
1849+-- Temporary solution for lacking of generic derivation of Arbitrary
1850+-- We use generics-sop, as it's much more concise than directly using GHC.Generics
1851+--
1852+-- This will be unneeded after https://github.com/nick8325/quickcheck/pull/112
1853+-- is merged and released
1854+sopArbitrary :: forall a. (Generic a, SOP.GTo a, SOP.All SOP.SListI (SOP.GCode a), SOP.All2 Arbitrary (SOP.GCode a)) => Gen a
1855+sopArbitrary = fmap SOP.gto sopArbitrary'
1856+
1857+sopArbitrary' :: forall xss. (SOP.All SOP.SListI xss, SOP.All2 Arbitrary xss) => Gen (SOP.SOP SOP.I xss)
1858+sopArbitrary' = SOP.hsequence =<< elements (SOP.apInjs_POP $ SOP.hcpure p arbitrary)
1859+ where
1860+ p :: Proxy Arbitrary
1861+ p = Proxy