Homework-4/src/ClassSchedule/Model.elm

69 lines
1.2 KiB
Elm

module ClassSchedule.Model exposing (..)
import Dict exposing (..)
type Department
= ComputerScience
| Mathematics
| Art
| Biology
type alias Crn = (Department, Int)
type DayOfWeek
= Monday
| Tuesday
| Wednesday
| Thursday
| Friday
| Saturday
| Sunday
type DayHalf = AM | PM
type alias Time = (Int, Int, DayHalf)
flipDayHalf : DayHalf -> DayHalf
flipDayHalf dh =
case dh of
AM -> PM
PM -> AM
addHours : Int -> Time -> Time
addHours hh (h, m, dh) =
if h + hh >= 12
then (h + hh - 12, m, flipDayHalf dh)
else (h + hh, m, dh)
addMinutes : Int -> Time -> Time
addMinutes mm (h, m, dh) =
let
remainder = modBy 60 (m + mm)
hh = (m + mm) // 60
in
addHours hh (h, remainder, dh)
type alias Course =
{ crn : Crn
, name : String
, instructors : List String
, times : List (DayOfWeek, Time, Time)
}
type CourseStatus = NotAdded | Added
type alias Flags = ()
type Msg
= SearchInput String
| SelectTerm String
| SelectCourse Int
| AddCourse Int
| RemoveCourse Int
type alias Model =
{ terms : Dict String (List (CourseStatus, Course))
, term : String
, selected : Maybe Int
, searchInput : String
}