Homework-4/src/Main.elm

64 lines
1.6 KiB
Elm

module Main exposing (..)
import ClassSchedule.Model exposing (..)
import ClassSchedule.View exposing (..)
import Browser exposing (Document, document)
import Dict exposing (..)
import Tuple exposing (..)
oneHour : Time -> (Time, Time)
oneHour t = (t, addMinutes 50 t)
nAm : Int -> Time
nAm i = (i, 0, AM)
nPm : Int -> Time
nPm i = (i, 0, PM)
onDays : List DayOfWeek -> (Time, Time) -> List (DayOfWeek, Time, Time)
onDays dds (t1, t2) = List.map (\d -> (d, t1, t2)) dds
classes : List Course
classes =
[ { crn = (ComputerScience, 544)
, name = "Operating Systems II"
, instructors = ["Yeongjin Jang"]
, times = onDays [Tuesday, Thursday] <| oneHour <| nAm 8
}
, { crn = (ComputerScience, 480)
, name = "Translators"
, instructors = ["Rob Hess"]
, times = onDays [Tuesday, Thursday] <| oneHour <| nAm 10
}
, { crn = (ComputerScience, 583)
, name = "Advanced Functional Programming"
, instructors = ["Eric Walkingshaw"]
, times = onDays [Monday, Wednesday] <| oneHour <| nAm 10
}
]
terms : Dict String (List (CourseStatus, Course))
terms = Dict.singleton "Spring 2021"
<| List.map (pair None) classes
init : Flags -> (Model, Cmd Msg)
init () = ({ terms = terms, term = "Spring 2021", searchInput = "" }, Cmd.none)
view : Model -> Document Msg
view m =
{ title = "Course Scheduler"
, body = [ viewModel m ]
}
update : Msg -> Model -> (Model, Cmd Msg)
update msg m = (m, Cmd.none)
subscriptions : Model -> Sub Msg
subscriptions m = Sub.none
main = document
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}