nationstates 0.1.0.3 → 0.2.0.0
raw patch · 7 files changed
+27/−18 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- NationStates: withContext :: String -> (Context -> IO a) -> IO a
+ NationStates: newContext :: String -> IO Context
+ NationStates.Types: type WAVote = Maybe Bool
- NationStates.Nation: gavote :: Nation (Maybe Bool)
+ NationStates.Nation: gavote :: Nation WAVote
- NationStates.Nation: scvote :: Nation (Maybe Bool)
+ NationStates.Nation: scvote :: Nation WAVote
- NationStates.Types: readWAVote :: String -> Maybe (Maybe Bool)
+ NationStates.Types: readWAVote :: String -> Maybe WAVote
- NationStates.Types: showWAVote :: Maybe Bool -> String
+ NationStates.Types: showWAVote :: WAVote -> String
Files
- NationStates.hs +7/−9
- NationStates/Core.hs +1/−1
- NationStates/Nation.hs +4/−3
- NationStates/Region.hs +2/−1
- NationStates/Types.hs +10/−2
- README.md +2/−1
- nationstates.cabal +1/−1
NationStates.hs view
@@ -1,7 +1,7 @@ module NationStates ( Context(),- withContext,+ newContext, -- * Core types module NationStates.Types,@@ -17,17 +17,15 @@ import NationStates.Types --- | Create a 'Context', and pass it to the provided function.------ The 'Context' will be closed automatically when the function returns.-withContext+-- | Create a new 'Context'.+newContext :: String -- ^ User agent- -> (Context -> IO a)- -> IO a-withContext userAgent f = withManager tlsManagerSettings $ \man -> do+ -> IO Context+newContext userAgent = do+ man <- newManager tlsManagerSettings limit <- newRateLimit delay- f Context {+ return Context { contextManager = man, contextRateLimit = rateLimit limit, contextUserAgent = userAgent
NationStates/Core.hs view
@@ -77,7 +77,7 @@ -- -- @ -- motto :: NS String--- motto = makeNS \"motto\" Nothing \"MOTTO\"+-- motto = makeNS \"motto\" \"MOTTO\" -- @ -- -- For more complex requests (e.g. nested elements), try 'makeNS'' instead.
NationStates/Nation.hs view
@@ -21,7 +21,8 @@ -- import qualified NationStates.Nation as Nation -- import Text.Printf ----- main = 'NationStates.withContext' "ExampleBot/2000" $ \\c -> do+-- main = do+-- c <- 'NationStates.newContext' "ExampleBot/2000" -- (name, motto) <- Nation.'run' "Montesardo-East Adanzi" -- ((,) \<$\> Nation.'name' \<*\> Nation.'motto') c -- printf "%s has the motto: %s\\n" name motto@@ -171,14 +172,14 @@ -- | General assembly vote. -- -- > Just True-gavote :: Nation (Maybe Bool)+gavote :: Nation WAVote gavote = Nation . fmap (expect "General Assembly vote" readWAVote) $ makeNS "gavote" "GAVOTE" -- | Security council vote. -- -- > Nothing-scvote :: Nation (Maybe Bool)+scvote :: Nation WAVote scvote = Nation . fmap (expect "Security Council vote" readWAVote) $ makeNS "scvote" "SCVOTE"
NationStates/Region.hs view
@@ -19,7 +19,8 @@ -- import qualified NationStates.Region as Region -- import Text.Printf ----- main = 'NationStates.withContext' "ExampleBot/2000" $ \\c -> do+-- main = do+-- c <- 'NationStates.newContext' "ExampleBot/2000" -- (name, numnations, delegate) <- Region.'run' "Pony Lands" -- ((,,) \<$\> Region.'name' \<*\> Region.'numnations' \<*\> Region.'delegate') c -- printf "%s has %d nations. Its delegate is %s\\n" name numnations delegate
NationStates/Types.hs view
@@ -108,14 +108,22 @@ TyrannyByMajority -> "Tyranny by Majority" -readWAVote :: String -> Maybe (Maybe Bool)+-- | A vote in the General Assembly or Security Council.+--+-- @Just True@ and @Just False@ mean \"for\" and \"against\"+-- respectively, while @Nothing@ means that the nation did not vote at+-- all.+type WAVote = Maybe Bool+++readWAVote :: String -> Maybe WAVote readWAVote s = case s of "UNDECIDED" -> Just Nothing "FOR" -> Just $ Just True "AGAINST" -> Just $ Just False _ -> Nothing -showWAVote :: Maybe Bool -> String+showWAVote :: WAVote -> String showWAVote v = case v of Nothing -> "UNDECIDED" Just True -> "FOR"
README.md view
@@ -42,7 +42,8 @@ import qualified NationStates.Nation as Nation import Text.Printf -main = withContext "ExampleBot/2000" $ \c -> do+main = do+ c <- newContext "ExampleBot/2000" (name, motto) <- Nation.run "Montesardo-East Adanzi" shards c printf "%s has the motto: %s\n" name motto where
nationstates.cabal view
@@ -1,5 +1,5 @@ name: nationstates-version: 0.1.0.3+version: 0.2.0.0 synopsis: NationStates API client description: NationStates API client