Lambdajudge 1.0.0.3 → 1.0.0.4
raw patch · 3 files changed
+65/−2 lines, 3 files
Files
- Lambdajudge.cabal +2/−2
- src/DataStructures.hs +50/−0
- src/Utility.hs +13/−0
Lambdajudge.cabal view
@@ -1,5 +1,5 @@ name: Lambdajudge-version: 1.0.0.3+version: 1.0.0.4 cabal-version: >=1.10 build-type: Simple license: MIT@@ -26,7 +26,7 @@ process >= 1.2.3.0 && < 1.3.0.0 default-language: Haskell2010 hs-source-dirs: src- exposed-modules: Lambdajudge+ exposed-modules: Lambdajudge, DataStructures, Utility test-suite spec default-language: Haskell2010
+ src/DataStructures.hs view
@@ -0,0 +1,50 @@+{-# LANGUAGE FlexibleContexts #-}++module DataStructures where++import Control.Monad.State+import Control.Monad.Writer+import Control.Monad.Error++-- | counts number of times code has been evaluated against test cases+type ProcCount = Int++-- | Require logging, state and need to throw exceptions during computation+type LJMonad a = WriterT String (StateT ProcCount (ErrorT String IO)) a++-- | Content of the input file+type TestCase = String++-- | Content of the output file+type Answer = String++-- | group together a problem atatement, its input and outputs and max allowed time limit+data Problem = Problem {+ problemStatement :: String,+ testCases :: [(TestCase,Answer)],+ problemSetterCode :: String,+ timeLimit :: Int+}++-- | Contest is a list of problems+data Contest = Contest {+ problems :: [Problem]+}++-- | Status code determines the result of evaluation of the submitted code+data StatusCode = AC -- Accepted+ | WA -- Wrong Answer+ | TLE -- Time Limit Exceeded+ | NZEC -- Non zero exit code+ deriving (Eq,Show)++type SubmissionResult = [ (TestCase , StatusCode) ]++-- | All that is required to run a mueval command+data MuevalCommand = MuevalCommand {+ expression :: String,+ testData :: String,+ ansData :: String,+ solutionFile :: String,+ maxRunTime :: Int+} deriving Show
+ src/Utility.hs view
@@ -0,0 +1,13 @@+module Utility where+import Data.Char+import System.IO++-- | removes newlines from both ends of text+trim :: String -> String+trim = let f = reverse . dropWhile (=='\n') in f . f++-- | reads contents of a file+getFileContents :: String -> IO String+getFileContents fileName = do+ inh <- openFile fileName ReadMode+ hGetContents inh