packages feed

cruncher-types 1.0.1 → 1.0.2

raw patch · 3 files changed

+13/−18 lines, 3 files

Files

cruncher-types.cabal view
@@ -1,5 +1,5 @@ name:                cruncher-types-version:             1.0.1+version:             1.0.2 synopsis:            Request and Response types for Eval.so's API description:   You are not likely to find this useful unless you are building a library for
src/Evalso/Cruncher/FinalResult.hs view
@@ -4,8 +4,7 @@ -- Stability   : stable -- -- The highest level of a response that Cruncher deals with. Contains only the--- final result of a sandbox run, including compilation, execution, and output--- files (which are base64-encoded).+-- final result of a sandbox run, including compilation and execution.  module Evalso.Cruncher.FinalResult (FinalResult (..)) where @@ -14,33 +13,25 @@ import Control.Applicative import Control.Monad (mzero) import Data.Aeson-import Data.ByteString (ByteString)-import Data.Map (Map)  -- | The final result for a given request. -----   This contains the 'SandboxResult' obtained from both evaluation and---   compilation as well as any files which resulted from performing the---   above steps. Such files should placed in @~/output/@ of the evaluation.--- --   This data type also handles error handling, in the form of types. data FinalResult   = FinalResult     {       compile     :: Maybe SandboxResult -- ^ The compilation result, if any     , run         :: Maybe SandboxResult -- ^ The execution result, if any-    , outputFiles :: Map String ByteString -- ^ Base64-encoded output files     }   | NoSuchLanguage   | SELinuxNotEnforcing   deriving (Eq, Show)  instance ToJSON FinalResult where-  toJSON (FinalResult compile' run' outputFiles') = object+  toJSON (FinalResult compile' run') = object     [       "compile"     .= compile'     , "run"         .= run'-    , "outputFiles" .= outputFiles'     ]    -- | TODO: i18n@@ -59,5 +50,4 @@   parseJSON (Object v) = FinalResult <$>                              v .: "compile"                          <*> v .: "run"-                         <*> v .: "outputFiles"   parseJSON _          = mzero
src/Evalso/Cruncher/SandboxResult.hs view
@@ -13,24 +13,28 @@ import Control.Applicative import Control.Monad (mzero) import Data.Aeson+import Data.ByteString (ByteString)+import Data.Map (Map) import Data.Text (Text)  -- | Describes the result we get back after performing an evaluation (or --   compilation). This is almost always wrapped in 'IO'. data SandboxResult = SandboxResult {-    stdout   :: Text-  , stderr   :: Text-  , wallTime :: Int-  , exitCode :: Int+    stdout      :: Text -- ^ Standard output stream+  , stderr      :: Text -- ^ Standard error stream+  , wallTime    :: Int -- ^ How long the process took+  , exitCode    :: Int -- ^ The exit code returned by the process+  , outputFiles :: Map String ByteString  -- ^ Base64-encoded output files } deriving (Eq, Show)  instance ToJSON SandboxResult where-  toJSON (SandboxResult stdout' stderr' wallTime' exitCode') = object+  toJSON (SandboxResult stdout' stderr' wallTime' exitCode' outputFiles') = object     [       "stdout"   .= stdout'     , "stderr"   .= stderr'     , "wallTime" .= wallTime'     , "exitCode" .= exitCode'+    , "outputFiles" .= outputFiles'     ]  instance FromJSON SandboxResult where@@ -39,4 +43,5 @@                          <*> v .: "stderr"                          <*> v .: "wallTime"                          <*> v .: "exitCode"+                         <*> v .: "outputFiles"   parseJSON _          = mzero