packages feed

mapquest-api 0.3 → 0.3.1

raw patch · 2 files changed

+10/−13 lines, 2 files

Files

mapquest-api.cabal view
@@ -1,5 +1,5 @@ name:                mapquest-api-version:             0.3+version:             0.3.1 synopsis:            Bindings to the MapQuest API description:         This library provides a high-level interface to the MapQuest API. Currently only the "geocoding" API (street address to coordinates) is provided, but the functionality is straightforward to extend. homepage:            https://github.com/ocramz/mapquest-api
src/Web/API/MapQuest/Geocoding.hs view
@@ -56,14 +56,9 @@ -- example request : -- GET http://www.mapquestapi.com/geocoding/v1/address?key=KEY&location=Washington,DC -----request ::-     -- T.Text  -- ^ API key (available for free on <https://developer.mapquest.com>)-     GeoQuery -- ^ Query address-  -> WebApiM MapQuest (Maybe (Coords Float))+request :: (FromJSON a, Floating a) =>  +     GeoQuery +  -> WebApiM MapQuest (Maybe (Coords a)) request q = do   key <- asks (apiKey . credentials)    r <- req GET apiRootPath NoReqBody lbsResponse (opts' key)@@ -83,14 +78,16 @@ -- -- >>> runRequest key (GQFree "Ngong Ping 360, Hong Kong") -- Just (Coords {lat = 22.264412, long = 114.16706})-runRequest ::-  Creds -> GeoQuery -> IO (Maybe (Coords Float))+runRequest :: (FromJSON a, Floating a) => +     Creds     -- ^ API key (available for free on <https://developer.mapquest.com>)+  -> GeoQuery  -- ^ Location to be queried+  -> IO (Maybe (Coords a)) runRequest k q = do   h <- createHandle k undefined   evalWebApiIO h (request q)  -decoder1 :: LBS.ByteString -> Maybe (Coords Float)+decoder1 :: (FromJSON a, Floating a) =>  LBS.ByteString -> Maybe (Coords a) decoder1 dat = do   r <- decode dat   flip parseMaybe r $ \obj -> do @@ -103,7 +100,7 @@     (loc0 : _) <- res0 .: "locations"     return loc0 -decodeLatLong :: Object -> Parser (Coords Float)+decodeLatLong :: (FromJSON a, Floating a) => Object -> Parser (Coords a) decodeLatLong loc = do     ll <- loc .: "latLng"     Coords <$> ll .: "lat" <*> ll .: "lng"