git.iko.soy/typeable/bloodhound
on master help sign in
formatting
commit828444795c7553aa0bb3691146a662f38795c12e authorChris Allen <cma@bitemyapp.com> dateSun 13 Apr 2014, 20:20 (13 years ago) parentdd0a228
1 file changed+15−2
README.org+15−2
README.org+15−2
@@ -196,13 +196,26 @@ let maybeResult = decode body :: Maybe (EsResult Tweet)
196196let eitherResult = decode body :: Either String (EsResult Tweet)
197197
198198-- 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}}})
200209
201210-- _source in EsResult is parametric, we dispatch the type by passing in what we expect (Tweet) as a parameter to EsResult.
202211
203212-- use the _source record accessor to get at your document
204213λ> fmap _source result
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}})
214+Right (Tweet {user = "bitemyapp"
215+ , postDate = 2009-06-18 00:00:10 UTC
216+ , message = "Use haskell!"
217+ , age = 10000
218+ , location = Location {lat = 40.12, lon = -71.34}})
206219
207220#+END_SRC
208221