-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Haskell bindings to the MaxMind GeoIPCity database via the C library
--   
--   This library provides fast, idiomatic Haskell bindings to MaxMind's
--   GeoIPCity IP-based geolocation C API.
--   
--   Make sure you have the MaxMind C API installed before installing this
--   library, as it depends on the C API.
--   
--   MaxMind GeoIP City database allows geo-location lookups from IP
--   addresses.
--   
--   To get started, you can download the latest binary database
--   distribution from: <a>http://www.maxmind.com/app/geolitecity</a>
@package hs-GeoIP
@version 0.3

module Data.Geolocation.GeoIP

-- | Type representing an established connection to a GeoIPCity database
data GeoDB
data GeoIPOption

-- | Collapse &amp; combine multiple <a>GeoIPOption</a>s into one
combineOptions :: [GeoIPOption] -> GeoIPOption
standard :: GeoIPOption
memory_cache :: GeoIPOption
check_cache :: GeoIPOption
index_cache :: GeoIPOption
mmap_cache :: GeoIPOption

-- | Return data for a geolocation lookup
data GeoIPRecord
GeoIPRecord :: !ByteString -> !ByteString -> !ByteString -> !ByteString -> !ByteString -> !ByteString -> !Double -> !Double -> !Int -> !ByteString -> !Int -> GeoIPRecord
[geoCountryCode] :: GeoIPRecord -> !ByteString
[geoCountryCode3] :: GeoIPRecord -> !ByteString
[geoCountryName] :: GeoIPRecord -> !ByteString
[geoRegion] :: GeoIPRecord -> !ByteString
[geoCity] :: GeoIPRecord -> !ByteString
[geoPostalCode] :: GeoIPRecord -> !ByteString
[geoLatitude] :: GeoIPRecord -> !Double
[geoLongitude] :: GeoIPRecord -> !Double
[geoAreaCode] :: GeoIPRecord -> !Int
[geoContinentCode] :: GeoIPRecord -> !ByteString
[geoAccuracyRadius] :: GeoIPRecord -> !Int

-- | Open the binary GeoIP data file with the given options.
--   
--   This would open a file and cache in memory:
--   
--   <pre>
--   openGeoDB "GeoCity.dat" memory_cache
--   </pre>
--   
--   The memory on the C side is automatically freed by the Haskell GC when
--   appropriate.
openGeoDB :: GeoIPOption -> String -> IO GeoDB

-- | Geo-locate by given IP Adress
--   
--   <pre>
--   geoLocateByIPAddress db "123.123.123.123"
--   </pre>
geoLocateByIPAddress :: GeoDB -> ByteString -> IO (Maybe GeoIPRecord)

-- | Geo-locate by given IP number. Call <a>mkIpNum</a> on a <a>String</a>
--   ip address to convert to IP number.
--   
--   <pre>
--   geoLocateByIPNum db 12336939327338
--   </pre>
geoLocateByIPNum :: GeoDB -> Integer -> IO (Maybe GeoIPRecord)
geoStringByIPAddress :: GeoDB -> ByteString -> IO (Maybe ByteString)
geoStringByIPNum :: GeoDB -> Integer -> IO (Maybe ByteString)

-- | Convert a string IP adress to IPNum
mkIpNum :: ByteString -> Maybe Integer
instance GHC.Show.Show Data.Geolocation.GeoIP.GeoIPRecord
instance GHC.Classes.Eq Data.Geolocation.GeoIP.GeoIPRecord
instance Control.DeepSeq.NFData Data.Geolocation.GeoIP.GeoIPRecord
