git.iko.soy/typeable/bloodhound
on master help sign in
Merge pull request #143 from 23Skidoo/patch-1

Fix an example.

commit255e39e1dabb91a741365d53c0af5ec1a5763f1d authorChris Allen <cma@bitemyapp.com> dateTue 18 Oct 2016, 12:23 (10 years ago) parent6fbdfb7b1ee4dc
4 files changed+38−39
.gitignore+2 README.md+3−4 src/Database/Bloodhound/Client.hs+3−4 tests/tests.hs+30−31
.gitignore+2
@@ -1,9 +1,11 @@
11cabal.sandbox.config
22.cabal-sandbox/
33dist/
4+dist-newstyle/
45.project
56.dist-buildwrapper/
67.DS_Store
8+TAGS
79*.hi
810*.o
911bloodhound-*-docs/
README.md+3−4
@@ -181,10 +181,9 @@ data TweetMapping = TweetMapping deriving (Eq, Show)
181181:{
182182instance ToJSON TweetMapping where
183183 toJSON TweetMapping =
184− object ["tweet" .=
185− object ["properties" .=
186− object ["location" .=
187− object ["type" .= ("geo_point" :: Text)]]]]
184+ object ["properties" .=
185+ object ["location" .=
186+ object ["type" .= ("geo_point" :: Text)]]]
188187:}
189188
190189resp <- withBH' $ putMapping testIndex testMapping TweetMapping
src/Database/Bloodhound/Client.hs+3−4
@@ -140,10 +140,9 @@ import Database.Bloodhound.Types
140140-- >>> :{
141141--instance ToJSON TweetMapping where
142142-- toJSON TweetMapping =
143−-- object ["tweet" .=
144−-- object ["properties" .=
145−-- object ["location" .=
146−-- object ["type" .= ("geo_point" :: Text)]]]]
143+-- object ["properties" .=
144+-- object ["location" .=
145+-- object ["type" .= ("geo_point" :: Text)]]]
147146--data Location = Location { lat :: Double
148147-- , lon :: Double } deriving (Eq, Generic, Show)
149148--data Tweet = Tweet { user :: Text
tests/tests.hs+30−31
@@ -177,47 +177,44 @@ data ParentMapping = ParentMapping deriving (Eq, Show)
177177
178178instance ToJSON ParentMapping where
179179 toJSON ParentMapping =
180− object ["parent" .=
181− object ["properties" .=
182− object [ "user" .= object ["type" .= ("string" :: Text)]
183− -- Serializing the date as a date is breaking other tests, mysteriously.
184− -- , "postDate" .= object [ "type" .= ("date" :: Text)
185− -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
186− , "message" .= object ["type" .= ("string" :: Text)]
187− , "age" .= object ["type" .= ("integer" :: Text)]
188− , "location" .= object ["type" .= ("geo_point" :: Text)]
189− ]]]
180+ object ["properties" .=
181+ object [ "user" .= object ["type" .= ("string" :: Text)]
182+ -- Serializing the date as a date is breaking other tests, mysteriously.
183+ -- , "postDate" .= object [ "type" .= ("date" :: Text)
184+ -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
185+ , "message" .= object ["type" .= ("string" :: Text)]
186+ , "age" .= object ["type" .= ("integer" :: Text)]
187+ , "location" .= object ["type" .= ("geo_point" :: Text)]
188+ ]]
190189
191190data ChildMapping = ChildMapping deriving (Eq, Show)
192191
193192instance ToJSON ChildMapping where
194193 toJSON ChildMapping =
195− object ["child" .=
196− object ["_parent" .= object ["type" .= ("parent" :: Text)]
197− , "properties" .=
198− object [ "user" .= object ["type" .= ("string" :: Text)]
199− -- Serializing the date as a date is breaking other tests, mysteriously.
200− -- , "postDate" .= object [ "type" .= ("date" :: Text)
201− -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
202− , "message" .= object ["type" .= ("string" :: Text)]
203− , "age" .= object ["type" .= ("integer" :: Text)]
204− , "location" .= object ["type" .= ("geo_point" :: Text)]
205− ]]]
194+ object ["_parent" .= object ["type" .= ("parent" :: Text)]
195+ , "properties" .=
196+ object [ "user" .= object ["type" .= ("string" :: Text)]
197+ -- Serializing the date as a date is breaking other tests, mysteriously.
198+ -- , "postDate" .= object [ "type" .= ("date" :: Text)
199+ -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
200+ , "message" .= object ["type" .= ("string" :: Text)]
201+ , "age" .= object ["type" .= ("integer" :: Text)]
202+ , "location" .= object ["type" .= ("geo_point" :: Text)]
203+ ]]
206204
207205data TweetMapping = TweetMapping deriving (Eq, Show)
208206
209207instance ToJSON TweetMapping where
210208 toJSON TweetMapping =
211− object ["tweet" .=
212− object ["properties" .=
213− object [ "user" .= object ["type" .= ("string" :: Text)]
214− -- Serializing the date as a date is breaking other tests, mysteriously.
215− -- , "postDate" .= object [ "type" .= ("date" :: Text)
216− -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
217− , "message" .= object ["type" .= ("string" :: Text)]
218− , "age" .= object ["type" .= ("integer" :: Text)]
219− , "location" .= object ["type" .= ("geo_point" :: Text)]
220− ]]]
209+ object ["properties" .=
210+ object [ "user" .= object ["type" .= ("string" :: Text)]
211+ -- Serializing the date as a date is breaking other tests, mysteriously.
212+ -- , "postDate" .= object [ "type" .= ("date" :: Text)
213+ -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
214+ , "message" .= object ["type" .= ("string" :: Text)]
215+ , "age" .= object ["type" .= ("integer" :: Text)]
216+ , "location" .= object ["type" .= ("geo_point" :: Text)]
217+ ]]
221218
222219exampleTweet :: Tweet
223220exampleTweet = Tweet { user = "bitemyapp"
@@ -623,8 +620,10 @@ instance Arbitrary Day where
623620 arbitrary = ModifiedJulianDay <$> (2000 +) <$> arbitrary
624621 shrink = (ModifiedJulianDay <$>) . shrink . toModifiedJulianDay
625622
623+#if !MIN_VERSION_QuickCheck(2,9,0)
626624instance Arbitrary a => Arbitrary (NonEmpty a) where
627625 arbitrary = liftA2 (:|) arbitrary arbitrary
626+#endif
628627
629628arbitraryScore :: Gen Score
630629arbitraryScore = fmap getPositive <$> arbitrary