git.iko.soy/typeable/bloodhound
on master help sign in
formatting
8284447Chris Allen
README.org+15−2
@@ -196,13 +196,26 @@ let maybeResult = decode body :: Maybe (EsResult Tweet)
196let eitherResult = decode body :: Either String (EsResult Tweet)
196let eitherResult = decode body :: Either String (EsResult Tweet)
197
197
198-- print eitherResult should look like:
198-- print eitherResult should look like:
199−Right (EsResult {_index = "twitter", _type = "tweet", _id = "1", _version = 2, found = Just True, _source = Tweet {user = "bitemyapp", postDate = 2009-06-18 00:00:10 UTC, message = "Use haskell!", age = 10000, location = Location {lat = 40.12, lon = -71.34}}})
199+Right (EsResult {_index = "twitter"
200+ , _type = "tweet"
201+ , _id = "1"
202+ , _version = 2
203+ , found = Just True
204+ , _source = Tweet {user = "bitemyapp"
205+ , postDate = 2009-06-18 00:00:10 UTC
206+ , message = "Use haskell!"
207+ , age = 10000
208+ , location = Location {lat = 40.12, lon = -71.34}}})
200
209
201-- _source in EsResult is parametric, we dispatch the type by passing in what we expect (Tweet) as a parameter to EsResult.
210-- _source in EsResult is parametric, we dispatch the type by passing in what we expect (Tweet) as a parameter to EsResult.
202
211
203-- use the _source record accessor to get at your document
212-- use the _source record accessor to get at your document
204λ> fmap _source result
213λ> fmap _source result
214+Right (Tweet {user = "bitemyapp"
215+ , postDate = 2009-06-18 00:00:10 UTC
216+ , message = "Use haskell!"
217+ , age = 10000
205−Right (Tweet {user = "bitemyapp", postDate = 2009-06-18 00:00:10 UTC, message = "Use haskell!", age = 10000, location = Location {lat = 40.12, lon = -71.34}})
218+ , location = Location {lat = 40.12, lon = -71.34}})
206
219
207#+END_SRC
220#+END_SRC
208
221