student.hs 1013 Bytes
Newer Older
1
{-# LANGUAGE TemplateHaskell, DeriveGeneric #-}
2 3

-- | Provides data types for the student information. Data is read from YAML files.
4
module Student
5 6 7
  ( Student(..)
  , Students(..)
  ) where
8 9 10

import Control.Exception
import Data.Aeson.TH
11
import Data.Aeson.Types
12
import qualified Data.HashMap.Strict as Map
13
import Data.Hashable
14
import qualified Data.Text as T
15
import Data.Yaml
16 17 18
import GHC.Generics (Generic)

data Student = Student
19 20 21 22 23 24 25 26
  { std_displayName :: T.Text
  , std_employeeNumber :: T.Text
  , std_givenName :: T.Text
  , std_mail :: T.Text
  , std_sAMAccountName :: T.Text
  , std_sn :: T.Text
  , std_track :: Int
  } deriving (Eq, Show, Generic)
27 28 29

instance Hashable Student

30 31 32 33 34
data Students = Students
  { stds_course :: T.Text
  , stds_semester :: T.Text
  , stds_students :: Map.HashMap T.Text Student
  } deriving (Eq, Show)
35

36 37
-- Students (Map.HashMap T.Text Student)
$(deriveJSON defaultOptions {fieldLabelModifier = drop 4} ''Student)
38

39
$(deriveJSON defaultOptions {fieldLabelModifier = drop 5} ''Students)