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


-- | NationStates API client
--   
--   NationStates API client
@package nationstates
@version 0.5.0.0


-- | Simple rate limiting combinator.
module NationStates.RateLimit
data RateLimit

-- | Create a new rate limiter with the specified delay.
--   
--   The rate limiter is thread-safe, and can be shared between threads.
newRateLimit :: Rational -> IO RateLimit

-- | Run the given action, pausing as necessary to keep under the rate
--   limit.
rateLimit :: RateLimit -> IO a -> IO a

-- | Create a new rate limiter with the same lock but a different delay.
setDelay :: Rational -> RateLimit -> RateLimit


-- | Data structures used by NationStates.
module NationStates.Types

-- | Nation category.
--   
--   This datum summarizes a nation's personal, economic, and political
--   freedoms.
data WACategory
Anarchy :: WACategory
AuthoritarianDemocracy :: WACategory
BenevolentDictatorship :: WACategory
CapitalistParadise :: WACategory
Capitalizt :: WACategory
CivilRightsLovefest :: WACategory
CompulsoryConsumeristState :: WACategory
ConservativeDemocracy :: WACategory
CorporateBordello :: WACategory
CorporatePoliceState :: WACategory
CorruptDictatorship :: WACategory
DemocraticSocialists :: WACategory

-- | This category has two variations: "<i>Father</i> Knows Best State" and
--   "<i>Mother</i> Knows Best State".
FatherKnowsBestState :: FatherOrMother -> WACategory
FreeMarketParadise :: WACategory
InoffensiveCentristDemocracy :: WACategory
IronFistConsumerists :: WACategory
IronFistSocialists :: WACategory
LeftLeaningCollegeState :: WACategory
LeftWingUtopia :: WACategory
LiberalDemocraticSocialists :: WACategory
LibertarianPoliceState :: WACategory
MoralisticDemocracy :: WACategory
NewYorkTimesDemocracy :: WACategory
PsychoticDictatorship :: WACategory
RightWingUtopia :: WACategory
ScandinavianLiberalParadise :: WACategory
TyrannyByMajority :: WACategory

-- | Differentiates between a <i>Father</i> or <i>Mother</i> Knows Best
--   State.
data FatherOrMother
Father :: FatherOrMother
Mother :: FatherOrMother
readWACategory :: String -> Maybe WACategory
showWACategory :: WACategory -> String

-- | A vote in the General Assembly or Security Council.
--   
--   <tt>Just True</tt> and <tt>Just False</tt> mean "for" and "against"
--   respectively, while <tt>Nothing</tt> means that the nation did not
--   vote at all.
type WAVote = Maybe Bool
readWAVote :: String -> Maybe WAVote
readWAVote' :: String -> Maybe (Maybe WAVote)
showWAVote :: WAVote -> String
readWAStatus :: String -> Maybe Bool
showWAStatus :: Bool -> String
instance GHC.Show.Show NationStates.Types.WACategory
instance GHC.Read.Read NationStates.Types.WACategory
instance GHC.Classes.Ord NationStates.Types.WACategory
instance GHC.Classes.Eq NationStates.Types.WACategory
instance GHC.Show.Show NationStates.Types.FatherOrMother
instance GHC.Read.Read NationStates.Types.FatherOrMother
instance GHC.Classes.Ord NationStates.Types.FatherOrMother
instance GHC.Classes.Eq NationStates.Types.FatherOrMother


-- | Low-level tools for querying the NationStates API.
--   
--   Most of the time, you should use the high-level wrappers in e.g.
--   <a>NationStates.Nation</a> instead. But if you need something not
--   provided by these wrappers, then feel free to use this module
--   directly.
module NationStates.Core

-- | A request to the NationStates API.
--   
--   <ul>
--   <li>Construct an <tt>NS</tt> using <a>makeNS</a> or
--   <a>makeNS'</a>.</li>
--   <li>Compose <tt>NS</tt> values using the <a>Applicative</a>
--   interface.</li>
--   <li>Execute an <tt>NS</tt> using <a>requestNS</a>.</li>
--   </ul>
--   
--   This type wraps a query string, along with a function that parses the
--   response. The funky type machinery keeps these two parts in sync, as
--   long as you stick to the <a>Applicative</a> interface.
--   
--   <pre>
--   type NS a = (<a>Query</a>, Query -&gt; <a>Element</a> -&gt; a)
--   </pre>
type NS = Compose ((,) Query) (Compose ((->) Query) ((->) Element))

-- | Construct a request for a single shard.
--   
--   For example, this code requests the <a>"motto"</a> shard:
--   
--   <pre>
--   motto :: NS String
--   motto = makeNS "motto" "MOTTO"
--   </pre>
--   
--   For more complex requests (e.g. nested elements), try <a>makeNS'</a>
--   instead.
makeNS :: String -> String -> NS String

-- | Construct a request.
makeNS' :: Query -> (Query -> Element -> a) -> NS a

-- | Perform a request on the NationStates API.
requestNS :: Maybe (String, String) -> NS a -> Context -> IO a

-- | The version of the NationStates API used by this package.
--   
--   Every request to NationStates includes this number. This means that if
--   the response format changes, existing code will continue to work under
--   the old API.
--   
--   This number should match the current API version, as given by
--   <a>https://www.nationstates.net/cgi-bin/api.cgi?a=version</a>. If not,
--   please file an issue.
apiVersion :: Integer

-- | Keeps track of the set of shards to request.
data Query
Query :: Map String (Set (Maybe Integer)) -> Map String String -> Map String String -> Query
[queryShards] :: Query -> Map String (Set (Maybe Integer))
[queryOptions] :: Query -> Map String String
[queryParams] :: Query -> Map String String

-- | Create a query for a single shard.
shard :: String -> Query

-- | Create a query for a single shard, with an extra ID.
--   
--   For example, the <tt>censusscore-23</tt> shard would be written as:
--   <tt>shard' "censusscore" 23</tt>.
shard' :: String -> Integer -> Query

-- | Add extra <tt>;</tt>-delimited arguments.
withOptions :: [(String, String)] -> Query

-- | Add extra <tt>&amp;</tt>-delimited arguments.
withParams :: [(String, String)] -> Query

-- | Keeps track of rate limits and TLS connections.
--   
--   You should create a single <a>Context</a> at the start of your
--   program, then share it between multiple threads and requests.
data Context
Context :: Manager -> (forall a. IO a -> IO a) -> Bool -> String -> Context
[contextManager] :: Context -> Manager
[contextRateLimit] :: Context -> forall a. IO a -> IO a
[contextIsSecure] :: Context -> Bool
[contextUserAgent] :: Context -> String

-- | Split a list by the given predicate, dropping empty sublists.
--   
--   <pre>
--   &gt;&gt;&gt; wordsBy (== ',') "the_vines,motesardo-east_adanzi,yellowapple"
--   ["the_vines", "montesardo-east_adanzi", "yellowapple"]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; wordsBy (== ',') ""
--   []
--   </pre>
wordsBy :: (a -> Bool) -> [a] -> [[a]]

-- | Parse a string using the <a>Read</a> instance. Succeeds if there is
--   exactly one valid result.
readMaybe :: Read a => String -> Maybe a

-- | Parse an input string using the given parser function.
--   
--   If parsing fails, raise an <a>error</a>.
--   
--   <pre>
--   &gt;&gt;&gt; (expect "integer" &lt;*&gt; readMaybe) "42" :: Integer
--   42
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; (expect "integer" &lt;*&gt; readMaybe) "butts" :: Integer
--   *** Exception: expected integer but got: butts
--   </pre>
expect :: String -> String -> Maybe a -> a

-- | Return the value only if the given predicate is true.
--   
--   <pre>
--   &gt;&gt;&gt; pureIf (&gt; 0) 5 :: Maybe Integer
--   Just 5
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; pureIf (&gt; 0) (-2) :: Maybe Integer
--   Nothing
--   </pre>
pureIf :: Alternative f => (a -> Bool) -> a -> f a
instance GHC.Show.Show NationStates.Core.Query
instance GHC.Base.Monoid NationStates.Core.Query


-- | The Region API.
--   
--   This module should be imported qualified, to prevent name clashes:
--   
--   <pre>
--   import NationStates
--   import qualified NationStates.Region as Region
--   </pre>
--   
--   In general, this module follows the terminology used in the
--   <a>official documentation</a>.
--   
--   Here's a short example:
--   
--   <pre>
--   import NationStates
--   import qualified NationStates.Region as Region
--   import Text.Printf
--   
--   main = do
--       c &lt;- <a>newContext</a> "ExampleBot/2000"
--       (name, numnations, delegate) &lt;- Region.<a>run</a> "Pony Lands"
--           ((,,) &lt;$&gt; Region.<a>name</a> &lt;*&gt; Region.<a>numnations</a> &lt;*&gt; Region.<a>delegate</a>) c
--       printf "%s has %d nations. Its delegate is %s\n" name numnations delegate
--   </pre>
module NationStates.Region

-- | A request to the Region API.
newtype Region a
Region :: NS a -> Region a
[unRegion] :: Region a -> NS a

-- | Perform a request to the Region API.
run :: String -> Region a -> Context -> IO a

-- | Region name.
--   
--   <pre>
--   "Pony Lands"
--   </pre>
name :: Region String

-- | Factbook, in BBCode format.
--   
--   <pre>
--   "[b]We&amp;#39;ve got ponies, therefore your argument is invalid..."
--   </pre>
factbook :: Region String

-- | Number of nations in the region.
--   
--   <pre>
--   112
--   </pre>
numnations :: Region Integer

-- | List of nations in the region.
--   
--   <pre>
--   ["urmanian","enatai","unfitting_doors","lykosia","trotterdam"]
--   </pre>
nations :: Region [String]

-- | Region delegate.
--   
--   Returns <tt>Nothing</tt> when the region has no delegate.
--   
--   <pre>
--   Just "princess_luna"
--   </pre>
delegate :: Region (Maybe String)

-- | The number of endorsements earned by the delegate.
--   
--   Returns <tt>0</tt> when the region has no delegate.
--   
--   <pre>
--   22
--   </pre>
delegatevotes :: Region Integer

-- | The number of votes for and against the current General Assembly
--   resolution.
--   
--   Returns <tt>Nothing</tt> when there is no proposal at vote.
--   
--   <pre>
--   Just (28,11)
--   </pre>
gavote :: Region (Maybe (Integer, Integer))

-- | The number of votes for and against the current Security Council
--   resolution.
--   
--   Returns <tt>Nothing</tt> when there is no proposal at vote.
--   
--   <pre>
--   Just (20,34)
--   </pre>
scvote :: Region (Maybe (Integer, Integer))

-- | Region founder.
--   
--   Returns <tt>Nothing</tt> when the region is founderless.
--   
--   <pre>
--   Just "magical_equestria"
--   </pre>
founder :: Region (Maybe String)

-- | Regional power.
--   
--   <pre>
--   "High"
--   </pre>
power :: Region String

-- | Regional flag.
--   
--   <pre>
--   Just "http://www.nationstates.net/images/flags/uploads/rflags/pony_lands__478033.png"
--   </pre>
flag :: Region (Maybe String)

-- | Region embassies.
--   
--   <pre>
--   ["New Lunar Republic","Tareldanore"]
--   </pre>
embassies :: Region [String]

-- | Region tags.
--   
--   <pre>
--   ["Silly","Monarchist","Large"]
--   </pre>
tags :: Region [String]
instance GHC.Base.Applicative NationStates.Region.Region
instance GHC.Base.Functor NationStates.Region.Region


-- | The Nation API.
--   
--   This module should be imported qualified, to prevent name clashes:
--   
--   <pre>
--   import NationStates
--   import qualified NationStates.Nation as Nation
--   </pre>
--   
--   In general, this module follows the terminology used in the
--   <a>official documentation</a>, except when it clashes with Haskell
--   keywords. For instance, the <tt>type</tt> shard has been renamed to
--   <a>type_</a>.
--   
--   Here's a short example:
--   
--   <pre>
--   import NationStates
--   import qualified NationStates.Nation as Nation
--   import Text.Printf
--   
--   main = do
--       c &lt;- <a>newContext</a> "ExampleBot/2000"
--       (name, motto) &lt;- Nation.<a>run</a> "Montesardo-East Adanzi"
--           ((,) &lt;$&gt; Nation.<a>name</a> &lt;*&gt; Nation.<a>motto</a>) c
--       printf "%s has the motto: %s\n" name motto
--   </pre>
module NationStates.Nation

-- | A request to the Nation API.
newtype Nation a
Nation :: NS a -> Nation a
[unNation] :: Nation a -> NS a

-- | Perform a request to the Nation API.
run :: String -> Nation a -> Context -> IO a

-- | Short name.
--   
--   <pre>
--   "Testlandia"
--   </pre>
name :: Nation String

-- | Full name, including pre-title.
--   
--   <pre>
--   "The Republic of Testlandia"
--   </pre>
fullname :: Nation String

-- | Nation type.
--   
--   <pre>
--   "Republic"
--   </pre>
type_ :: Nation String

-- | Motto.
--   
--   <pre>
--   "It's a feature!"
--   </pre>
motto :: Nation String

-- | Nation category.
--   
--   <pre>
--   InoffensiveCentristDemocracy
--   </pre>
category :: Nation WACategory

-- | Whether the nation is in the World Assembly.
--   
--   <pre>
--   True
--   </pre>
wa :: Nation Bool

-- | List of endorsements received.
--   
--   <pre>
--   ["jlink","translenia","the_vines"]
--   </pre>
endorsements :: Nation [String]

-- | General assembly vote.
--   
--   <pre>
--   Just True
--   </pre>
gavote :: Nation (Maybe WAVote)

-- | Security council vote.
--   
--   <pre>
--   Nothing
--   </pre>
scvote :: Nation (Maybe WAVote)

-- | Description of civil rights, economy, and political freedoms.
--   
--   <pre>
--   ("Excellent","Strong","Very Good")
--   </pre>
freedom :: Nation (String, String, String)

-- | Resident region.
--   
--   <pre>
--   "Testregionia"
--   </pre>
region :: Nation String

-- | Population, in millions.
--   
--   <pre>
--   25764
--   </pre>
population :: Nation Integer

-- | Income tax, percent.
--   
--   <pre>
--   83.6
--   </pre>
tax :: Nation Double

-- | National animal.
--   
--   <pre>
--   "sea-snake"
--   </pre>
animal :: Nation String

-- | A short phrase describing the animal.
--   
--   <pre>
--   "is also the nation's favorite main course"
--   </pre>
animaltrait :: Nation String

-- | Currency.
--   
--   <pre>
--   "☆star☆"
--   </pre>
currency :: Nation String

-- | Flag URL.
--   
--   <pre>
--   "http://www.nationstates.net/images/flags/Switzerland.png"
--   </pre>
flag :: Nation String

-- | A suitable banner for this nation.
--   
--   <pre>
--   "v1"
--   </pre>
banner :: Nation String

-- | A list of suitable banners for this nation.
--   
--   <pre>
--   ["v1","o4","b14","t23","m3"]
--   </pre>
banners :: Nation [String]

-- | Query today's census.
--   
--   Returns the current census ID, along with its value.
--   
--   <pre>
--   (24,6.0)
--   </pre>
censusscore :: Nation (Integer, Double)

-- | Query a census by its census ID.
--   
--   <pre>
--   94.0
--   </pre>
censusscore' :: Integer -> Nation Double
instance GHC.Base.Applicative NationStates.Nation.Nation
instance GHC.Base.Functor NationStates.Nation.Nation

module NationStates

-- | Keeps track of rate limits and TLS connections.
--   
--   You should create a single <a>Context</a> at the start of your
--   program, then share it between multiple threads and requests.
data Context

-- | Create a new <a>Context</a>.
newContext :: String -> IO Context

-- | Create a new <a>Context</a>, with extra options.
newContext' :: String -> Bool -> IO Context


-- | The Authentication API.
--   
--   See <a>https://www.nationstates.net/pages/api.html#authentication</a>.
--   
--   Here's a short example:
--   
--   <pre>
--   import NationStates
--   import qualified NationStates.Nation as Nation
--   import qualified NationStates.Verify as Nation
--   
--   main = do
--       c &lt;- <a>newContext</a> "ExampleBot/2000"
--       ok &lt;- Nation.run "The Vines" (Nation.verify checksum token) c
--       putStrLn $ if ok then "Success" else "Failure"
--     where
--       checksum = "CCT60sf2CfylDqSNzCMleqsvxrwjiG-9Zw4TXZjdMmk"
--       token = Just "testing123"
--   </pre>
module NationStates.Verify

-- | Add an authentication token to an existing <a>Nation</a> request.
verify :: String -> Maybe String -> Nation Bool
