katt-0.2.0.1: Client for the Kattis judge system.

Safe HaskellNone

Utils.Katt.Utils

Description

Contains shared type declarations and various utility functions.

Synopsis

Documentation

type ConfigEnvInternal m = StateT ConfigState mSource

Configuration layer consisting of configuration state.

type ConfigEnv m = EitherT ErrorDesc (ConfigEnvInternal m)Source

Configuration layer wrapped with error handling.

type ConnEnvInternal m = StateT Connection (ConfigEnvInternal m)Source

Connection layer with connection state layered on the configuration layer.

type ConnEnv m = EitherT ErrorDesc (ConnEnvInternal m)Source

Connection layer wrapped with error handling.

type AuthEnv m = EitherT ErrorDesc (ReaderT ByteString (ConnEnvInternal m))Source

Authentication layer with token state and error handling, wrapping the connection layer.

type Submission = (KattisProblem, [FilePath])Source

Submissions consist of a problem identifier and a set of file paths.

type ErrorDesc = ByteStringSource

Error description alias.

type SubmissionId = IntegerSource

Submissions are identified with an integer id.

type ProblemSession = IntegerSource

Problem sessions are identified with an integer id.

type ProjectState = KattisProblemSource

Project-specific state consists of the problem name.

data ConfigState Source

Global configuration, initialized from the .kattisrc file.

Constructors

ConfigState 

Fields

user :: ByteString

Username.

apiKey :: ByteString

API token (hash).

host :: ByteString

Host to be considered as service.

loginPage :: ByteString

URL to login page, relative host.

submitPage :: ByteString

URL to submit page, relative host.

project :: Maybe ProjectState

Project-specific state, optionally loaded.

Instances

data KattisProblem Source

A Kattis problem.

Constructors

ProblemId Integer

Problem ID, unique.

ProblemName ByteString

Associated name of the problem.

data KattisLanguage Source

Language used in submission.

Constructors

LangCplusplus

C++.

LangJava

Java.

LangC

C.

loginSuccess :: ByteStringSource

Server response indicating successful login.

inputTestExtension :: FilePathSource

Extension of input test files.

outputTestExtension :: FilePathSource

Extension of reference ouput test files.

programName :: ByteStringSource

Name of this program.

configDir :: ByteStringSource

Relative path to project-specific configuration directory.

testFolder :: FilePathSource

Relative path to folder containing tests.

problemAddress :: ByteStringSource

URL to page with problem information, relative to host.

unWrapTrans :: (Monad m, MonadTrans t) => EitherT e m a -> EitherT e (t m) aSource

Lift some error monad one layer.

tryIO :: MonadIO m => IO a -> EitherT ErrorDesc m aSource

Execute an IO action and catch any exceptions.

tryIOMsg :: MonadIO m => ByteString -> IO a -> EitherT ErrorDesc m aSource

Execute an IO action and catch any exceptions, tagged with description.

terminateOnFailure :: MonadIO m => ErrorDesc -> EitherT ErrorDesc m a -> m aSource

Evaluate an error action and terminate process upon failure.

makeSignedRequest :: RequestBuilder () -> AuthEnv IO RequestSource

Sign an existing HTTP request with a temporary token.

defaultRequest :: RequestBuilder ()Source

Default HTTP request.

reestablishConnection :: ConnEnv IO ()Source

Reestablish an existing connection. Useful in order to avoid timeouts related to keep-alive.

retrievePublicPage :: ByteString -> ConnEnv IO ByteStringSource

Retrieve a publically available page, using HTTP GET.

retrievePrivatePage :: ByteString -> AuthEnv IO ByteStringSource

Retrieve a page requiring authentication, using HTTP GET.

makeRequest :: Request -> ConnEnv IO ByteStringSource

Make a HTTP request and retrieve the server response body.

extractSessionHeader :: ByteString -> Maybe ByteStringSource

Extract correct temporary token from cookie header string.

authenticate :: ConnEnv IO ByteStringSource

Authenticate an existing connection, returns a temporary token. Basically the API token is used to acquire a session-specific token.

retrieveProblemId :: KattisProblem -> ConnEnv IO IntegerSource

Retrieve problem ID of a Kattis problem.

retrieveProblemName :: KattisProblem -> ConnEnv IO ByteStringSource

Retrieve problem name of a Kattis problem.