packages feed

schedule-planner 1.0.0.0 → 1.0.0.1

raw patch · 3 files changed

+51/−11 lines, 3 filesnew-component:exe:schedule-planner-standalone

Files

schedule-planner.cabal view
@@ -1,5 +1,5 @@ name: schedule-planner-version: 1.0.0.0+version: 1.0.0.1 cabal-version: >=1.10 build-type: Simple license: LGPL-3@@ -11,8 +11,8 @@ description:     Executable program for calculating layouts for fixed grid schedules as     are used in many universities and schools.-    The primary data format for in- and output is json, a deployable server-    instance of this software is planned.+    The primary data format for in- and output is json. A deployable server+    instance of this software is also available. category: Data, Convenience, Planning author: Justus Adam <development@justusadam.com> -- data-dir: ""@@ -45,12 +45,44 @@   ghc-options:     -Wall ++executable schedule-planner-standalone+  build-depends:+    base >= 4.7 && <5,+    containers >= 0.5,+    aeson >= 0.8,+    options >= 1.2,+    transformers >= 0.4,+    bytestring >= 0.10,+    text >= 1.2,+    warp >= 3.0,+    wai >= 3.0,+    mtl >= 2.2,+    http-types >= 0.8+  main-is: Main.hs+  buildable: True+  other-modules:+    SchedulePlanner.App+    SchedulePlanner.Calculator+    SchedulePlanner.Serialize+    SchedulePlanner.Server+    SchedulePlanner.Calculator.Scale+    SchedulePlanner.Calculator.Solver+  default-language: Haskell2010+  hs-source-dirs: src+  ghc-options:+    -Wall+    -static+    -optl-pthread+    -optl-static+    -O2+ source-repository head   type:     git   location: git://github.com/JustusAdam/schedule-planner.git  source-repository this   type:     git-  branch:   stable+  branch:   master   location: git://github.com/JustusAdam/schedule-planner.git-  tag:      1.0.0.0+  tag:      1.0.0.1
src/SchedulePlanner/App.hs view
@@ -27,8 +27,8 @@ import           Data.Text.IO               as TIO (putStrLn) import           SchedulePlanner.Calculator (calcFromMap, mapToSubject, weigh, MappedSchedule) import           SchedulePlanner.Serialize  (DataFile (DataFile),-                                             formatSchedule, shortSubject)-import Data.String (fromString)+                                             formatSchedule, shortSubject, scheduleToJson)+import           Data.String (fromString)   -- |Print a string if debug is enabled@@ -50,7 +50,7 @@     (fromString . ("Error:" ++) . show )     (maybe       "\"No schedule could be calculated\""-      (encode . concatMap Map.elems)+      (encode . map scheduleToJson)     . calculate)   . eitherDecode 
src/SchedulePlanner/Serialize.hs view
@@ -16,6 +16,7 @@   , shortSubject   , DataFile(DataFile)   , eitherDecode+  , scheduleToJson   ) where  import           Control.Arrow              as Arrow (first)@@ -26,7 +27,7 @@ import           Data.Aeson.Types           (Parser) import qualified Data.ByteString.Lazy       as LBS (readFile, writeFile) import           Data.List                  as List (intercalate)-import qualified Data.Map                   as Map (Map, lookup, toList)+import qualified Data.Map                   as Map (Map, lookup, toList, elems) import           Data.Text                  as T (Text, pack) import           SchedulePlanner.Calculator (Lesson (..), MappedSchedule,                                              Rule (..), Target (..), Timeslot,@@ -77,7 +78,7 @@   -- |Base structure of the input JSON file-data DataFile = DataFile [Rule] [Lesson Text]+data DataFile = DataFile [Rule] [Lesson Text] deriving (Show)   instance FromJSON a => FromJSON (Lesson a) where@@ -118,7 +119,7 @@       fromScope :: Object -> Text -> Parser Target       fromScope obj "day"  = Day  <$> obj .: ruleDayKey       fromScope obj "slot" = Slot <$> obj .: ruleSlotKey-      fromScope obj "cell" = Cell <$> obj .: ruleSlotKey <*> obj .: ruleDayKey+      fromScope obj "cell" = Cell <$> obj .: ruleDayKey <*> obj .: ruleSlotKey       fromScope _ _        = error "unknown input"  -- I am so sorry   parseJSON _         = mzero @@ -135,6 +136,13 @@       [ lessonKey .= l       , ruleKey   .= r       ]+++scheduleToJson :: ToJSON a => MappedSchedule a -> Value+scheduleToJson = object . sequenceA+  [ (.=) lessonKey . Map.elems+  , (.=) "weight"  . totalWeight+  ]   -- |Convert a suitable Map to a JSON Value