-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Command line interface to interact with Codeforces. -- -- Please see the README on GitHub at -- https://github.com/farbodsz/codeforces-cli#readme @package codeforces-cli @version 0.1.0 module Codeforces.App.Table -- | A cell of a table consists of SGR styles and some text content data Cell Cell :: [SGR] -> Text -> Cell type Row = [Cell] -- | The table output is a list of row strings. type Table = [Text] -- | makeTable colConfigs rows returns a list of row -- strings including the header row makeTable :: [ColConfig] -> [Row] -> Table -- | Name and width of a column type ColConfig = (Text, Int) -- | Utility functions for producing and writing error logs. module Codeforces.Logging -- | Contains a brief, user-friendly error message and potential loggable -- data. data ErrorLog ErrorLog :: String -> Maybe String -> ErrorLog [elErrorMsg] :: ErrorLog -> String [elErrorLog] :: ErrorLog -> Maybe String -- | Produces an error and log using a single error message. mkErrorLog :: String -> ErrorLog -- | Takes an error message and error details and produces a pair of the -- message and full error details. (<~>) :: String -> String -> ErrorLog instance GHC.Show.Show Codeforces.Logging.ErrorLog -- | Common types used across the application. module Codeforces.Types.Common -- | ID of the contest. -- -- Not to be confused with contest round number. The ID appears in the -- contest URL, for example in: -- https://codeforces.com/contest/566/status. newtype ContestId ContestId :: Int -> ContestId [unContestId] :: ContestId -> Int -- | Codeforces user handle. newtype Handle Handle :: Text -> Handle [unHandle] :: Handle -> Text -- | Number of points gained for a submission or across a contest. type Points = Float -- | A letter, or letter with digit(s) indicating the problem index in a -- contest. type ProblemIndex = Text -- | User or problem rating. type Rating = Int instance GHC.Show.Show Codeforces.Types.Common.ContestId instance GHC.Classes.Ord Codeforces.Types.Common.ContestId instance GHC.Classes.Eq Codeforces.Types.Common.ContestId instance GHC.Show.Show Codeforces.Types.Common.Handle instance GHC.Classes.Ord Codeforces.Types.Common.Handle instance GHC.Classes.Eq Codeforces.Types.Common.Handle instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Common.Handle instance Data.Aeson.Types.ToJSON.ToJSON Codeforces.Types.Common.Handle instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Common.ContestId module Codeforces.Types.Contest data ScoringType ScoringCF :: ScoringType ScoringIOI :: ScoringType ScoringICPC :: ScoringType data ContestPhase Before :: ContestPhase Coding :: ContestPhase PendingSystemTest :: ContestPhase Finished :: ContestPhase data Contest Contest :: ContestId -> Text -> ScoringType -> ContestPhase -> Bool -> DiffTime -> Maybe UTCTime -> Contest [contestId] :: Contest -> ContestId [contestName] :: Contest -> Text [contestType] :: Contest -> ScoringType [contestPhase] :: Contest -> ContestPhase [contestFrozen] :: Contest -> Bool [contestDuration] :: Contest -> DiffTime [contestStartTime] :: Contest -> Maybe UTCTime instance GHC.Classes.Eq Codeforces.Types.Contest.ScoringType instance GHC.Show.Show Codeforces.Types.Contest.ScoringType instance GHC.Show.Show Codeforces.Types.Contest.ContestPhase instance GHC.Show.Show Codeforces.Types.Contest.Contest instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Contest.Contest instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Contest.ContestPhase instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Contest.ScoringType module Codeforces.Types.Party -- | Member of a party. data Member Member :: Handle -> Member [memberHandle] :: Member -> Handle data ParticipantType Contestant :: ParticipantType Practice :: ParticipantType Virtual :: ParticipantType Manager :: ParticipantType OutOfCompetition :: ParticipantType -- | Represents a party, participating in a contest. data Party Party :: Maybe ContestId -> [Member] -> ParticipantType -> Maybe Int -> Maybe Text -> Bool -> Maybe Int -> Maybe UTCTime -> Party [partyContestId] :: Party -> Maybe ContestId [partyMembers] :: Party -> [Member] [partyParticipantType] :: Party -> ParticipantType [partyTeamId] :: Party -> Maybe Int [partyTeamName] :: Party -> Maybe Text [partyIsGhost] :: Party -> Bool [partyRoom] :: Party -> Maybe Int [partyStartTime] :: Party -> Maybe UTCTime instance GHC.Show.Show Codeforces.Types.Party.Member instance GHC.Classes.Ord Codeforces.Types.Party.Member instance GHC.Classes.Eq Codeforces.Types.Party.Member instance GHC.Show.Show Codeforces.Types.Party.ParticipantType instance GHC.Classes.Ord Codeforces.Types.Party.ParticipantType instance GHC.Classes.Eq Codeforces.Types.Party.ParticipantType instance GHC.Show.Show Codeforces.Types.Party.Party instance GHC.Classes.Ord Codeforces.Types.Party.Party instance GHC.Classes.Eq Codeforces.Types.Party.Party instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Party.Party instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Party.ParticipantType instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Party.Member module Codeforces.Types.Problem type ProblemTag = Text data ProblemType Programming :: ProblemType Question :: ProblemType data Problem Problem :: Maybe ContestId -> Maybe Text -> ProblemIndex -> Text -> ProblemType -> Maybe Points -> Maybe Rating -> [ProblemTag] -> Problem -- | ID of a contest containing the problem. -- -- Note that a problem may appear in multiple contests (such as Div. 1 -- and Div. 2 variants of a contest), but this field only contains one. [problemContestId] :: Problem -> Maybe ContestId [problemSetName] :: Problem -> Maybe Text [problemIndex] :: Problem -> ProblemIndex [problemName] :: Problem -> Text [problemType] :: Problem -> ProblemType [problemPoints] :: Problem -> Maybe Points [problemRating] :: Problem -> Maybe Rating [problemTags] :: Problem -> [ProblemTag] data ProblemStats ProblemStats :: Maybe ContestId -> ProblemIndex -> Int -> ProblemStats [pStatContestId] :: ProblemStats -> Maybe ContestId [pStatProblemIndex] :: ProblemStats -> ProblemIndex [pStatSolvedCount] :: ProblemStats -> Int -- | Problem data returned by the API contains two lists: a list of -- problems followed by a list of corresponding problem statistics. data ProblemsResponse ProblemsResponse :: [Problem] -> [ProblemStats] -> ProblemsResponse [prProblems] :: ProblemsResponse -> [Problem] [prStats] :: ProblemsResponse -> [ProblemStats] instance GHC.Show.Show Codeforces.Types.Problem.ProblemType instance GHC.Show.Show Codeforces.Types.Problem.Problem instance GHC.Show.Show Codeforces.Types.Problem.ProblemStats instance GHC.Show.Show Codeforces.Types.Problem.ProblemsResponse instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Problem.ProblemsResponse instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Problem.ProblemStats instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Problem.Problem instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Problem.ProblemType module Codeforces.Types.Rank data RankColor Gray :: RankColor Green :: RankColor Cyan :: RankColor Blue :: RankColor Violet :: RankColor Orange :: RankColor Red :: RankColor type RatingBounds = (Rating, Rating) data Rank Rank :: Text -> RankColor -> RatingBounds -> Rank [rankName] :: Rank -> Text [rankColor] :: Rank -> RankColor [rankBounds] :: Rank -> RatingBounds -- | A list of all Codeforces ranks. ranks :: [Rank] -- | Finds the Rank that matches the supplied rating. getRank :: Rating -> Rank instance GHC.Show.Show Codeforces.Types.Rank.RankColor instance GHC.Classes.Eq Codeforces.Types.Rank.RankColor instance GHC.Show.Show Codeforces.Types.Rank.Rank instance GHC.Classes.Eq Codeforces.Types.Rank.Rank module Codeforces.Types.RatingChange data RatingChange RatingChange :: ContestId -> Text -> Handle -> Int -> UTCTime -> Rating -> Rating -> RatingChange [rcContestId] :: RatingChange -> ContestId [rcContestName] :: RatingChange -> Text [rcHandle] :: RatingChange -> Handle [rcRank] :: RatingChange -> Int [rcRatingUpdateDate] :: RatingChange -> UTCTime [rcOldRating] :: RatingChange -> Rating [rcNewRating] :: RatingChange -> Rating instance GHC.Show.Show Codeforces.Types.RatingChange.RatingChange instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.RatingChange.RatingChange module Codeforces.Types.Standings data ResultType -- | Means a party's points can decrease, e.g. if their solution fails -- during a system test. ResultPreliminary :: ResultType -- | Means a party can only increase points for this problem by submitting -- better solutions. ResultFinal :: ResultType data ProblemResult ProblemResult :: Points -> Maybe Int -> Int -> ResultType -> Maybe Int -> ProblemResult [prPoints] :: ProblemResult -> Points -- | Penalty (in ICPC meaning) of the party for this problem. [prPenalty] :: ProblemResult -> Maybe Int [prRejectedAttemptCount] :: ProblemResult -> Int [prType] :: ProblemResult -> ResultType -- | Number of seconds after the start of the contest before the -- submission, that brought maximal amount of points for this problem. [prBestSubmissionTime] :: ProblemResult -> Maybe Int -- | True if no solution has been submitted for this problem in the -- contest. prNotAttempted :: ProblemResult -> Bool data RanklistRow RanklistRow :: Party -> Int -> Points -> Int -> Int -> Int -> [ProblemResult] -> Maybe DiffTime -> RanklistRow [rrParty] :: RanklistRow -> Party [rrRank] :: RanklistRow -> Int [rrPoints] :: RanklistRow -> Points [rrPenalty] :: RanklistRow -> Int [rrSuccessfulHackCount] :: RanklistRow -> Int [rrUnsuccessfulHackCount] :: RanklistRow -> Int [rrProblemResults] :: RanklistRow -> [ProblemResult] -- | Time from the start of the contest to the last submission that added -- some points to the total score of the party. For IOI contests only. [rrLastSubmissionTime] :: RanklistRow -> Maybe DiffTime -- | The standings returned by the API consists of Contest details, -- the list of Problems and the requested portion of the standings -- list (a list of RanklistRows). data Standings Standings :: Contest -> [Problem] -> [RanklistRow] -> Standings [standingsContest] :: Standings -> Contest [standingsProblems] :: Standings -> [Problem] [standingsRanklist] :: Standings -> [RanklistRow] instance GHC.Show.Show Codeforces.Types.Standings.ResultType instance GHC.Show.Show Codeforces.Types.Standings.ProblemResult instance GHC.Show.Show Codeforces.Types.Standings.RanklistRow instance GHC.Show.Show Codeforces.Types.Standings.Standings instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Standings.Standings instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Standings.RanklistRow instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Standings.ProblemResult instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Standings.ResultType module Codeforces.Types.Submission data Verdict Failed :: Verdict Ok :: Verdict Partial :: Verdict CompilationError :: Verdict RuntimeError :: Verdict WrongAnswer :: Verdict PresentationError :: Verdict TimeLimitExceeded :: Verdict MemoryLimitExceeded :: Verdict IdlenessLimitExceeded :: Verdict SecurityViolated :: Verdict Crashed :: Verdict InputPreparationCrashed :: Verdict Challenged :: Verdict Skipped :: Verdict Testing :: Verdict Rejected :: Verdict -- | verdictText verdict returns a user-friendly text -- representation of the Verdict. verdictText :: Verdict -> Text -- | Testset used for judging a submission. data Testset Samples :: Testset Pretests :: Testset Tests :: Testset Challenges :: Testset data Submission Submission :: Int -> Maybe ContestId -> UTCTime -> DiffTime -> Problem -> Party -> Text -> Maybe Verdict -> Testset -> Int -> Int -> Int -> Maybe Points -> Submission [submissionId] :: Submission -> Int [submissionContestId] :: Submission -> Maybe ContestId -- | Time when the solution was submitted. [submissionTime] :: Submission -> UTCTime -- | The time passed after the start of the contest (or a virtual start for -- virtual parties), before the submission. [submissionRelativeTime] :: Submission -> DiffTime [submissionProblem] :: Submission -> Problem [submissionAuthor] :: Submission -> Party [submissionProgrammingLanguage] :: Submission -> Text [submissionVerdict] :: Submission -> Maybe Verdict [submissionTestset] :: Submission -> Testset [submissionPassedTestCount] :: Submission -> Int -- | Maximum time (in ms) consumed by the submission for one test. [submissionTimeConsumed] :: Submission -> Int -- | Maximum memory (in bytes) consumed by the submission for one test. [submissionMemoryConsumed] :: Submission -> Int -- | Number of scored points for IOI-like contests. [submissionPoints] :: Submission -> Maybe Points instance GHC.Classes.Eq Codeforces.Types.Submission.Verdict instance GHC.Show.Show Codeforces.Types.Submission.Verdict instance GHC.Show.Show Codeforces.Types.Submission.Testset instance GHC.Show.Show Codeforces.Types.Submission.Submission instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Submission.Submission instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Submission.Testset instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.Submission.Verdict module Codeforces.Types.User data User User :: Handle -> Maybe Text -> Maybe Text -> Rating -> Rating -> Maybe Text -> Maybe Text -> Maybe Text -> Int -> User [userHandle] :: User -> Handle [userFirstName] :: User -> Maybe Text [userLastName] :: User -> Maybe Text [userRating] :: User -> Rating [userMaxRating] :: User -> Rating [userCity] :: User -> Maybe Text [userCountry] :: User -> Maybe Text [userOrganization] :: User -> Maybe Text [userFriendOfCount] :: User -> Int instance GHC.Show.Show Codeforces.Types.User.User instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Types.User.User module Codeforces.Types module Codeforces.Config -- | Represents the user's configuration settings. -- -- The API key must first be generated on the Codeforces API page. -- An API key consists of two parameters: key and -- secret. -- -- To use the API key in a request, some parameters need to be generated -- from this configuration. data UserConfig UserConfig :: Handle -> Text -> Text -> UserConfig -- | Codeforces handle of the user [cfgHandle] :: UserConfig -> Handle -- | First part of the API key [cfgKey] :: UserConfig -> Text -- | Second part of the API key [cfgSecret] :: UserConfig -> Text -- | Contains the data needed to make an authorized GET request. See -- generateRequestParams. data AuthQuery AuthQuery :: Query -> String -> Text -> Text -> POSIXTime -> Int -> AuthQuery [aqOriginalQuery] :: AuthQuery -> Query [aqMethodName] :: AuthQuery -> String [aqKey] :: AuthQuery -> Text [aqSecret] :: AuthQuery -> Text [aqTime] :: AuthQuery -> POSIXTime [aqRand] :: AuthQuery -> Int -- | generateRequestParams config path query returns a -- query string with extra query items that are generated to allow for -- authorized access. -- -- The parameters are of the form: -- ?paramI=valueI&apiKey=key&time=time&apiSig=randhash -- -- -- Where -- -- -- --
--   rand/methodName?paramI=valueI&apiKey=key&time=time#secret
--   
generateRequestParams :: UserConfig -> String -> Query -> IO Query instance GHC.Show.Show Codeforces.Config.UserConfig instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Config.UserConfig instance Data.Aeson.Types.ToJSON.ToJSON Codeforces.Config.UserConfig module Codeforces.Response -- | An error that could occur during the retrieval and inital parsing of -- data from the Codeforces API. data ResponseError -- | Corresponds to a ResponseFail from the Codeforces API with -- the fail comment. ApiFail :: String -> ResponseError -- | Wrapper around JSONException, used if the successful JSON -- response could not be parsed. JsonError :: JSONException -> ResponseError -- | Wrapper around HttpException, used for situations like a failed -- connection. HttpError :: HttpException -> ResponseError -- | Converts a ResponseError to a friendly error message to -- display, and details that can be logged separately. responseErrorMsg :: ResponseError -> ErrorLog -- | getData path query is a general function for returning -- some result data from the Codeforces API. getData :: FromJSON a => String -> Query -> IO (Either ResponseError a) -- | getAuthorizedData config path query requests and -- returns some result data that requires authorization. getAuthorizedData :: FromJSON a => UserConfig -> String -> Query -> IO (Either ResponseError a) instance GHC.Show.Show Codeforces.Response.CodeforcesStatus instance GHC.Show.Show a => GHC.Show.Show (Codeforces.Response.CodeforcesResponse a) instance GHC.Show.Show Codeforces.Response.ResponseError instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (Codeforces.Response.CodeforcesResponse a) instance Data.Aeson.Types.FromJSON.FromJSON Codeforces.Response.CodeforcesStatus -- | Provides a way of dealing with errors encountered during the retrieval -- or processing of data from the Codeforces API. module Codeforces.Error -- | An error that may occur in this application. data CodeforcesError ResponseError :: ResponseError -> CodeforcesError StandingsEmpty :: CodeforcesError StandingsWithFriendsEmpty :: CodeforcesError VirtualNoResult :: CodeforcesError -- | Returns a human-friendly error message with error details. showE :: CodeforcesError -> ErrorLog -- | handleE m runs the computation m that may -- produce a CodeforcesError. If an error is encountered, its -- error message is printed. handleE :: IO (Either CodeforcesError a) -> IO () -- | Utility functions for formatting data. module Codeforces.App.Format -- | showText x is a Text version of show showText :: Show a => a -> Text -- | colored color text wraps some text around SGR codes to -- display it in the given color. colored :: Color -> Text -> Text rankColored :: RankColor -> Text -> Text convertRankColor :: RankColor -> Color -- | Like differenceCell but returns a Text rather than a -- Cell. diffColored :: Int -> Text indent :: Text fmtTimeConsumed :: Int -> Text fmtMemoryConsumed :: Int -> Text -- | Returns an approximate and human-friendly time difference. -- -- Possible options are: * "just now" * "5 seconds ago" * "X seconds ago" -- where X is a multiple of 10 * "X minutes ago" fmtDiffTime :: NominalDiffTime -> Text plainCell :: Text -> Cell coloredCell :: Color -> Text -> Cell blankCell :: Cell ratingCell :: Rating -> Cell -- | differenceCell diff colors a number red, white or -- green, depending on whether it's negative, 0, or positive. differenceCell :: Int -> Cell -- | verdictCell testset passedTestCount points verdict -- returns a cell displaying the status of a submission, such as -- Accepted or "Wrong answer on pretest 2". verdictCell :: Testset -> Int -> Maybe Points -> Maybe Verdict -> Cell module Codeforces.App.Watcher -- | Values used for watching output. data WatchState WatchState :: Table -> Maybe UTCTime -> WatchState [wsTable] :: WatchState -> Table [wsUpdateTime] :: WatchState -> Maybe UTCTime initWatchState :: WatchState -- | handleWatch shouldWatch m runs computation m -- once if shouldWatch is false, otherwise watchTable -- watches it. -- -- In the latter case, it clears the terminal and sets up terminal -- behaviour for watching data. handleWatch :: Bool -> IO (Either CodeforcesError Table) -> IO () -- | watchTable delaySecs m runs computation m -- every delaySecs amount of seconds. The terminal output from -- m is changed if the next run of m yields a different -- result. watchTable :: Int -> IO (Either CodeforcesError Table) -> StateT WatchState IO () -- | Takes a table with a potential error message and last successful -- update time, and returns the table with extra rows for various -- messages. -- -- When tables are displayed in watch mode, these extra rows are placed -- before the table: * The first displays a message for how to exit watch -- mode. * The second row displays errors if there are any and the last -- update time. * The third row is blank. addInfo :: Table -> Maybe CodeforcesError -> UTCTime -> Maybe UTCTime -> Table -- | truncateTable table x returns the table with the first -- x rows, or the original table if x is -- Nothing. truncateTable :: Table -> Maybe Int -> Table resetScreen :: IO () -- | Prevents any input into the terminal while running the IO computation. withDisabledStdin :: IO a -> IO a module Codeforces.App.Config -- | loadConfig returns the user configuration instance from the -- config file. loadConfig :: IO UserConfig -- | Creates a configuration file with user prompts. -- -- The user must decide whether to overwrite their configuration file if -- one already exists. setupConfig :: IO () module Codeforces.Virtual.Types virtualHandle :: Handle -- | A Party representing the user's virtual participation. virtualParty :: Party -- | Represents the virtual participation of the user in this contest. data VirtualUser VirtualUser :: Points -> Int -> Rating -> VirtualUser -- | Points scored in the virtual contest. [vuPoints] :: VirtualUser -> Points -- | User's penalty in the virtual contest. [vuPenalty] :: VirtualUser -> Int -- | Current rating of the user. [vuRating] :: VirtualUser -> Rating -- | Difference in rating between a user's current rating, and their rating -- following this contest. type Delta = Int -- | The seed is the expected ranking for each participant before the -- contest begins. -- -- A contestant's rating increases should they perform better than their -- seed, and decreases should they perform worse. type Seed = Float -- | The participation of a user in a contest. data Contestant Contestant :: Party -> Int -> Points -> Rating -> Contestant [contestantParty] :: Contestant -> Party [contestantRank] :: Contestant -> Int [contestantPoints] :: Contestant -> Points [contestantRating] :: Contestant -> Rating -- | Finds a single contestant from the given Party, or -- Nothing if none found. findContestant :: Party -> [Contestant] -> Maybe Contestant data ContestResults ContestResults :: [Contestant] -> Map Party Delta -> Map Rating Seed -> ContestResults [crContestants] :: ContestResults -> [Contestant] [crDeltas] :: ContestResults -> Map Party Delta [crSeeds] :: ContestResults -> Map Rating Seed -- | A virtual participation result data VirtualResult VirtualResult :: Int -> Delta -> Seed -> VirtualResult [virtualRank] :: VirtualResult -> Int [virtualDelta] :: VirtualResult -> Delta [virtualSeed] :: VirtualResult -> Seed instance GHC.Show.Show Codeforces.Virtual.Types.VirtualUser instance GHC.Show.Show Codeforces.Virtual.Types.Contestant instance GHC.Classes.Eq Codeforces.Virtual.Types.Contestant instance GHC.Show.Show Codeforces.Virtual.Types.ContestResults instance GHC.Show.Show Codeforces.Virtual.Types.VirtualResult -- | Implementation of the Open Codeforces Rating System described in -- Mike Mirzayanov's blog post. module Codeforces.Virtual.RatingCalculator -- | calculateContestResults previousRatings -- updatedRankings computes the contest results. calculateContestResults :: Map Handle Rating -> [RanklistRow] -> ContestResults module Codeforces.Virtual -- | Represents the virtual participation of the user in this contest. data VirtualUser VirtualUser :: Points -> Int -> Rating -> VirtualUser -- | Points scored in the virtual contest. [vuPoints] :: VirtualUser -> Points -- | User's penalty in the virtual contest. [vuPenalty] :: VirtualUser -> Int -- | Current rating of the user. [vuRating] :: VirtualUser -> Rating -- | A virtual participation result data VirtualResult VirtualResult :: Int -> Delta -> Seed -> VirtualResult [virtualRank] :: VirtualResult -> Int [virtualDelta] :: VirtualResult -> Delta [virtualSeed] :: VirtualResult -> Seed -- | Difference in rating between a user's current rating, and their rating -- following this contest. type Delta = Int -- | The seed is the expected ranking for each participant before the -- contest begins. -- -- A contestant's rating increases should they perform better than their -- seed, and decreases should they perform worse. type Seed = Float -- | Computes the results the user would have had, had they participated in -- this contest live with their current rating. calculateResult :: VirtualUser -> [RatingChange] -> [RanklistRow] -> Maybe VirtualResult module Codeforces.API -- | An error that could occur during the retrieval and inital parsing of -- data from the Codeforces API. data ResponseError -- | Corresponds to a ResponseFail from the Codeforces API with -- the fail comment. ApiFail :: String -> ResponseError -- | Wrapper around JSONException, used if the successful JSON -- response could not be parsed. JsonError :: JSONException -> ResponseError -- | Wrapper around HttpException, used for situations like a failed -- connection. HttpError :: HttpException -> ResponseError handleAPI :: IO (Either ResponseError a) -> ExceptT CodeforcesError IO a -- | getContests isGym returns a list of contests that may -- or may not be gym contests. getContests :: Bool -> IO (Either ResponseError [Contest]) -- | getContestStandings standingsParams returns -- information about the contest and a part of the standings list. getContestStandings :: StandingsParams -> IO (Either ResponseError Standings) -- | Like getContestStandings but returns the standings and the -- RatingChanges for each user participating. getContestStandings' :: StandingsParams -> IO (Either ResponseError (Standings, Map Handle RatingChange)) -- | Query parameters for retrieving contest standings. data StandingsParams StandingsParams :: ContestId -> Maybe Int -> Maybe Int -> Maybe Int -> Bool -> Maybe [Handle] -> StandingsParams -- | ID of the contest [paramContestId] :: StandingsParams -> ContestId -- | The starting index of the ranklist (1-based) [paramFrom] :: StandingsParams -> Maybe Int -- | The number of standing rows to return [paramRowCount] :: StandingsParams -> Maybe Int -- | If specified, only standings of this room are returned [paramRoom] :: StandingsParams -> Maybe Int -- | If true, all participations are included. Otherwise only -- Contestant participations are included. [paramUnofficial] :: StandingsParams -> Bool -- | If specified, the standings includes only these users. [paramHandles] :: StandingsParams -> Maybe [Handle] -- | getAllProblemData tags returns a -- ProblemsResponse filtered by the tags, if supplied. getAllProblemData :: [ProblemTag] -> IO (Either ResponseError ProblemsResponse) -- | getProblems tags returns a list of Problems -- containing the tags, if provided. getProblems :: [ProblemTag] -> IO (Either ResponseError [Problem]) -- | Like getProblems but returns a list of ProblemStats. getProblemStats :: [ProblemTag] -> IO (Either ResponseError [ProblemStats]) -- | getContestProblems contestId returns the list of -- problems for the given contest. -- -- This should be used instead of filtering results from -- getProblems for two main reasons: -- --
    --
  1. problemContestId can only refer to one contest, so problems -- appearing in multiple contests may not be filtered correctly.
  2. --
  3. getProblems returns larger output potentially affecting -- performance
  4. --
getContestProblems :: ContestId -> IO (Either ResponseError [Problem]) -- | getContestRatingChanges contestId returns a list of -- RatingChanges for the contest. getContestRatingChanges :: ContestId -> IO (Either ResponseError [RatingChange]) -- | getUserRatingHistory handle returns a list of -- RatingChanges for the requested user getUserRatingHistory :: Handle -> IO (Either ResponseError [RatingChange]) -- | getContestSubmissions contestId handle returns the -- submissions made by the user in the contest given by -- contestId getContestSubmissions :: ContestId -> Handle -> IO (Either ResponseError [Submission]) -- | getUserStatus handle from count returns the -- count most recent submissions by the user, starting from the -- from-th one. getUserStatus :: Handle -> Int -> Int -> IO (Either ResponseError [Submission]) -- | getUser handle returns the User with the given -- handle getUser :: Handle -> IO (Either ResponseError User) -- | getUsers handles returns a list of Users with -- the given handles getUsers :: [Handle] -> IO (Either ResponseError [User]) getFriends :: UserConfig -> IO (Either ResponseError [Handle]) -- | calculateVirtualResult contestId handle points penalty -- computes the rating change the user would gain had they competed in -- the contest live, and their expected ranking for the contest. calculateVirtualResult :: ContestId -> Handle -> Points -> Int -> IO (Either ResponseError (User, Maybe VirtualResult)) -- | Difference in rating between a user's current rating, and their rating -- following this contest. type Delta = Int -- | The seed is the expected ranking for each participant before the -- contest begins. -- -- A contestant's rating increases should they perform better than their -- seed, and decreases should they perform worse. type Seed = Float -- | A virtual participation result data VirtualResult VirtualResult :: Int -> Delta -> Seed -> VirtualResult [virtualRank] :: VirtualResult -> Int [virtualDelta] :: VirtualResult -> Delta [virtualSeed] :: VirtualResult -> Seed -- | Represents the user's configuration settings. -- -- The API key must first be generated on the Codeforces API page. -- An API key consists of two parameters: key and -- secret. -- -- To use the API key in a request, some parameters need to be generated -- from this configuration. data UserConfig UserConfig :: Handle -> Text -> Text -> UserConfig -- | Codeforces handle of the user [cfgHandle] :: UserConfig -> Handle -- | First part of the API key [cfgKey] :: UserConfig -> Text -- | Second part of the API key [cfgSecret] :: UserConfig -> Text instance GHC.Show.Show Codeforces.API.StandingsParams -- | Virtual contest/rating command. module Codeforces.App.Commands.VirtualCmd virtualRating :: ContestId -> Handle -> Points -> Int -> IO () module Codeforces.App.Options data Command AgendaCmd :: Command ContestsCmd :: ContestOpts -> Command FriendsCmd :: Command InfoCmd :: ContestId -> InfoOpts -> Command OpenCmd :: ContestId -> Command ProblemsCmd :: ProblemOpts -> Command RatingsCmd :: Handle -> Command SetupCmd :: Command StandingsCmd :: ContestId -> StandingOpts -> Command StatusCmd :: Handle -> StatusOpts -> Command UserCmd :: Handle -> Command VirtualCmd :: ContestId -> Handle -> Points -> Int -> Command data ContestOpts ContestOpts :: Bool -> Bool -> Bool -> ContestOpts [optIsGym] :: ContestOpts -> Bool [optIsPast] :: ContestOpts -> Bool [optIsUpcoming] :: ContestOpts -> Bool data InfoOpts InfoOpts :: Maybe Handle -> Bool -> InfoOpts [optHandle] :: InfoOpts -> Maybe Handle [optInfoWatch] :: InfoOpts -> Bool data ProblemOpts ProblemOpts :: Rating -> Rating -> ProblemOpts [optMinRating] :: ProblemOpts -> Rating [optMaxRating] :: ProblemOpts -> Rating data StandingOpts StandingOpts :: Bool -> Int -> Int -> Maybe Int -> Bool -> Bool -> StandingOpts [optShowUnofficial] :: StandingOpts -> Bool [optFromIndex] :: StandingOpts -> Int [optRowCount] :: StandingOpts -> Int [optRoom] :: StandingOpts -> Maybe Int [optFriends] :: StandingOpts -> Bool [optStandWatch] :: StandingOpts -> Bool data StatusOpts StatusOpts :: Int -> Int -> Bool -> StatusOpts [optStatusFrom] :: StatusOpts -> Int [optStatusCount] :: StatusOpts -> Int [optStatusWatch] :: StatusOpts -> Bool parseCommands :: IO Command instance GHC.Classes.Eq Codeforces.App.Options.ContestOpts instance GHC.Classes.Eq Codeforces.App.Options.InfoOpts instance GHC.Classes.Eq Codeforces.App.Options.ProblemOpts instance GHC.Classes.Eq Codeforces.App.Options.StandingOpts instance GHC.Classes.Eq Codeforces.App.Options.StatusOpts instance GHC.Classes.Eq Codeforces.App.Options.Command -- | User-related commands. module Codeforces.App.Commands.UserCmds userInfo :: Handle -> IO () userRatings :: Handle -> IO () userStatus :: Handle -> StatusOpts -> IO () userFriends :: UserConfig -> IO () -- | Standings command. module Codeforces.App.Commands.StandingsCmd standingsList :: ContestId -> UserConfig -> StandingOpts -> IO () -- | Problems command. module Codeforces.App.Commands.ProblemsCmd problemList :: ProblemOpts -> IO () -- | Contest-related commands. module Codeforces.App.Commands.ContestCmds contestList :: ContestOpts -> IO () contestInfo :: ContestId -> UserConfig -> InfoOpts -> IO () -- | openContest contestId opens the URL to the specified -- contest in the user's preferred web browser. openContest :: ContestId -> IO () module Codeforces.App.Commands module Codeforces.App