packages feed

advent-of-code-api 0.1.0.0 → 0.1.1.0

raw patch · 4 files changed

+35/−20 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Advent: SubIncorrect :: SubmitRes
+ Advent: SubIncorrect :: Maybe String -> SubmitRes

Files

CHANGELOG.md view
@@ -1,6 +1,16 @@ Changelog ========= +Version 0.1.1.0+---------------++*December 7, 2018*++<https://github.com/mstksg/advent-of-code-api/releases/tag/v0.1.1.0>++*   More robust parser for submission results.  Also now reports "hints" if+    possible.+ Version 0.1.0.0 --------------- 
README.md view
@@ -26,8 +26,8 @@ ```  Please use responsibly.  All actions are rate-limited to a default of one-request every three minutes, with ability to adjust up to as fast as a-hard-coded limit of one request per minute.+request every three seconds, with ability to adjust up to as fast as a+hard-coded limit of one request per second.  Note that leaderboard API is not yet supported. 
advent-of-code-api.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 4e6eb16d6e3c33671de42d74c0c48c7fedbfe536ad3d4eb20bbc4a0d625881df+-- hash: f03eec5006d16762ac8fed0ec107a02d10becc827816ae9aff936b1c94e41493  name:           advent-of-code-api-version:        0.1.0.0+version:        0.1.1.0 synopsis:       Advent of Code REST API bindings description:    Haskell bindings for Advent of Code REST API.  Please use responsibly!                 See README.md or "Advent" module for an introduction and tutorial.
src/Advent.hs view
@@ -38,8 +38,9 @@ -- 'runAoC' myOpts $ 'AoCSubmit' ('mkDay_' 10) 'Part1' "hello" -- @ ----- Please use responsibly.  All actions are rate-limited to a minimum of--- one request per minute.+-- Please use responsibly.  All actions are by default rate limited to one+-- per three seconds, but this can be adjusted to a hard-limited cap of one+-- per second. -- -- Note that leaderboard API is not yet supported. @@ -116,10 +117,11 @@     -- | Correct submission, including global rank (if reported, which     -- usually happens if rank is under 1000)     = SubCorrect (Maybe Integer)-    -- | Incorrect submission.  Check response text for hints (often, "too-    -- high" or "too low"), and also for the wait time required before the-    -- next submission.-    | SubIncorrect+    -- | Incorrect submission.  The 'Maybe' contains possible hints given+    -- by the server (usually "too low" or "too high").  Check response+    -- text for hints that the parser didn't catch, and also for the wait+    -- time required before the next submission.+    | SubIncorrect (Maybe String)     -- | Submission was rejected because an incorrect submission was     -- recently submitted.  Check response text for wait time.     | SubWait@@ -185,7 +187,7 @@ data AoCError     -- | A libcurl error, with response code and response body     = AoCCurlError CurlCode String-    -- | Tried to get interact with a challenge that has not yet been+    -- | Tried to interact with a challenge that has not yet been     -- released.  Contains the amount of time until release.     | AoCReleaseError NominalDiffTime     -- | The throttler limit is full.  Either make less requests, or adjust@@ -210,7 +212,7 @@       _aSessionKey :: String       -- | Year of challenge     , _aYear       :: Integer-      -- ^ Cache directory.  If 'Nothing' is given, one will be allocated+      -- | Cache directory.  If 'Nothing' is given, one will be allocated       -- using 'getTemporaryDirectory'.     , _aCache      :: Maybe FilePath       -- | Fetch results even if cached.  Still subject to throttling.@@ -219,7 +221,7 @@       -- | Throttle delay, in milliseconds.  Minimum is 1000000.  Default       -- is 3000000 (3 seconds).     , _aThrottle   :: Int-      -- ^ (Low-level usage) Extra 'CurlOption' options to feed to the+      -- | (Low-level usage) Extra 'CurlOption' options to feed to the       -- libcurl bindings.  Meant for things like proxy options and custom       -- SSL certificates.  You should normally not have to add anything       -- here, since the library manages cookies, request methods, etc. for@@ -352,7 +354,9 @@ parseSubmitRes :: Text -> SubmitRes parseSubmitRes t     | "the right answer!"       `T.isInfixOf` t = SubCorrect $ findRank t-    | "not the right answer."   `T.isInfixOf` t = SubIncorrect+    | "too high"                `T.isInfixOf` t = SubIncorrect $ Just "too high"+    | "too low"                 `T.isInfixOf` t = SubIncorrect $ Just "too low"+    | "not the right answer"    `T.isInfixOf` t = SubIncorrect Nothing     | "an answer too recently"  `T.isInfixOf` t = SubWait     | "solving the right level" `T.isInfixOf` t = SubInvalid     | otherwise                                 = SubUnknown@@ -369,12 +373,13 @@ -- | Pretty-print a 'SubmitRes' showSubmitRes :: SubmitRes -> String showSubmitRes = \case-    SubCorrect Nothing  -> "Correct"-    SubCorrect (Just r) -> printf "Correct (Rank %d)" r-    SubIncorrect        -> "Incorrect"-    SubWait             -> "Wait"-    SubInvalid          -> "Invalid"-    SubUnknown          -> "Unknown"+    SubCorrect Nothing    -> "Correct"+    SubCorrect (Just r)   -> printf "Correct (Rank %d)" r+    SubIncorrect Nothing  -> "Incorrect"+    SubIncorrect (Just h) -> printf "Incorrect (%s)" h+    SubWait               -> "Wait"+    SubInvalid            -> "Invalid"+    SubUnknown            -> "Unknown"  saverLoader :: AoC a -> SaverLoader (Either AoCError a) saverLoader = \case