From 58f5b808c151a801ab5fca2c84a71d3bfddce57d Mon Sep 17 00:00:00 2001 From: stuebinm Date: Wed, 17 Apr 2024 01:55:56 +0200 Subject: general housekeeping jumps to GHC2021 as default language, adds in some fields, moves the old org mode glossary to markdown, etc. --- CHANGELOG.md | 9 +++++-- GLOSSARY.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++ GLOSSARY.org | 66 --------------------------------------------- app/GenJS.hs | 14 +++++----- hie.yaml | 10 ------- lib/API.hs | 10 +++---- lib/Config.hs | 2 -- lib/Extrapolation.hs | 14 ++++------ lib/GTFS.hs | 24 ++++++----------- lib/Persist.hs | 22 +++++---------- lib/Server.hs | 15 ++++------- lib/Server/ControlRoom.hs | 7 ----- lib/Server/GTFS_RT.hs | 3 +-- lib/Server/Util.hs | 4 --- tracktrain.cabal | 23 +++++----------- 15 files changed, 119 insertions(+), 173 deletions(-) create mode 100644 GLOSSARY.md delete mode 100644 GLOSSARY.org delete mode 100644 hie.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 1df15d0..9ad039c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ -# Revision history for haskell-gtfs +# Revision history for tracktrain -## 0.1.0.0 -- YYYY-mm-dd + +## 0.0.2.0 -- 2024-05-?? +* Hopefully first version usable in production? + +## 0.0.1.0 -- ~ 2022-11-01 * First version. Released on an unsuspecting world. +* First version which could successfully send data to Google diff --git a/GLOSSARY.md b/GLOSSARY.md new file mode 100644 index 0000000..664edd9 --- /dev/null +++ b/GLOSSARY.md @@ -0,0 +1,69 @@ +# Glossary + +This is meant to give a rough overview of (train-related) terms used in +this code; both for others as a reference and for me so I can remember +to use them in a (somewhat) consistent way, since they are somewhat +arbitrary. I've tried to remain at least broadly close to the +terminology used by GTFS. + +## Terms + +(Calendar-)Date / Day +: A single, unique day (e.g. 1970-01-01). Usually used to indicate if a + *trip* is running on that day or not. + +Time (of Day) +: Time on a given day, given in seconds (though often displayed as + minutes) since midnight. If a trip crosses midnight it is treated as if + it took place entirely on the previous day, and times simply count up + beyond the total number of seconds in a day (note that that's a + timezone-series dependent number). + +Trip (don't confuse with Train) +: Used as in GTFS: a trip is a defined sequence of *stops*, referred to by + a number (called its trip ID, e.g. IC 94). Usually runs on multiple + days. Always has an associated *shape*. + + (might match your intuition for "train line") + +Stop +: A *station* with associated arrival/departure *time*. + +Station +: A train station. Tracktrain refers to each by an ID, and hopefully knows + its geolocation. + +Shape +: A sequence of geolocations describing a line between stations, + describing the physical railway along which trains travel. + +Train (don't confuse with Trip) +: A single instance of a *trip* on a concrete *date*. Tracktrain mostly + concerns itself with keeping track of those; the rest is just additional + stuff. + +Vehicle +: An actual, physical vehicle, which might act as the *train* going along + a *trip* on a certain *date*. + + For now tracktrain doesn't really care about them (but if it's curious + it might yet learn about them!) + +Announcement +: The thing that GTFS calls "Service Alert" --- a text message giving + human-readable information about some *train*. + +(Train-)Ping +: A single packet of data sent from a train's *OBU*. Might arrive in some + arbitrary order. + +Control Room +: The "admin interface" of tracktrain, which is not meant to be used by + on-board staff. + +On-Board Unit (OBU) +: A thing on a vehicle which does geolocation tracking and yells at + tracktrain about it. + + If we ever run into potential confusion regarding this term we're + probably way too professional to actually use tracktrain for anything. diff --git a/GLOSSARY.org b/GLOSSARY.org deleted file mode 100644 index 38cda75..0000000 --- a/GLOSSARY.org +++ /dev/null @@ -1,66 +0,0 @@ -#+TITLE: Glossary of Terms - -This is meant to give a rough overview of (train-related) terms used in this -code; both for others as a reference and for me so I can remember to use them -in a (somewhat) consistent way, since they are somewhat arbitrary. I've tried -to remain at least broadly close to the terminology used by GTFS. - -* Terms -** (Calendar-)Date / Day -A single, unique day (e.g. 1970-01-01). Usually used to indicate if a /trip/ -is running on that day or not. - -** Time (of Day) -Time on a given day, given in seconds (though often displayed as minutes) -since midnight. If a trip crosses midnight it is treated as if it took place -entirely on the previous day, and times simply count up beyond the total -number of seconds in a day (note that that's a timezone-series dependent -number). - -** Trip (don't confuse with Train) -Used as in GTFS: a trip is a defined sequence of /stops/, referred to by a -number (called its trip ID, e.g. IC 94). Usually runs on multiple days. -Always has an associated /shape/. - -(might match your intuition for "train line") - -** Stop -A /station/ with associated arrival/departure /time/. - -** Station -A train station. Tracktrain refers to each by an ID, and hopefully knows -its geolocation. - -** Shape -A sequence of geolocations describing a line between stations, describing -the physical railway along which trains travel. - -** Train (don't confuse with Trip) -A single instance of a /trip/ on a concrete /date/. Tracktrain mostly concerns -itself with keeping track of those; the rest is just additional stuff. - -** Vehicle -An actual, physical vehicle, which might act as the /train/ going along a -/trip/ on a certain /date/. - -For now tracktrain doesn't really care about them (but if it's curious it -might yet learn about them!) - -** Announcement -The thing that GTFS calls "Service Alert" — a text message giving -human-readable information about some /train/. - -** (Train-)Ping -A single packet of data sent from a train's /OBU/. Might arrive in some -arbitrary order. - -** Control Room -The "admin interface" of tracktrain, which is not meant to be used by on-board -staff. - -** On-Board Unit (OBU) -A thing on a vehicle which does geolocation tracking and yells at tracktrain -about it. - -If we ever run into potential confusion regarding this term we're probably -way too professional to actually use tracktrain for anything. diff --git a/app/GenJS.hs b/app/GenJS.hs index a580d23..1e7ba3a 100644 --- a/app/GenJS.hs +++ b/app/GenJS.hs @@ -4,12 +4,12 @@ -- bother with it module Main where -import Universum -import Servant.JS -import Servant.JS.Vanilla -import System.Environment (getArgs) +import Servant.JS +import Servant.JS.Vanilla +import System.Environment (getArgs) +import Universum -import API +import API apiJS :: Text -> Text apiJS url = jsForAPI (Proxy @API) (vanillaJSWith options) @@ -19,6 +19,6 @@ main :: IO () main = do args <- getArgs case args of - [] -> putText (apiJS "") + [] -> putText (apiJS "") [prefix] -> putText (apiJS (toText prefix)) - _ -> error "don't understand these options" + _ -> error "don't understand these options" diff --git a/hie.yaml b/hie.yaml deleted file mode 100644 index 4bc07c5..0000000 --- a/hie.yaml +++ /dev/null @@ -1,10 +0,0 @@ -cradle: - cabal: - - path: "app/Main.hs" - component: "tracktrain:exe:tracktrain" - - - path: "lib" - component: "lib:tracktrain" - - - path: "gtfs" - component: "tracktrain:lib:gtfs" diff --git a/lib/API.hs b/lib/API.hs index b0e12f6..b18ebdd 100644 --- a/lib/API.hs +++ b/lib/API.hs @@ -1,10 +1,6 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE TypeOperators #-} -{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE UndecidableInstances #-} -- | The sole authorative definition of this server's API, given as a Servant-style -- Haskell type. All other descriptions of the API are generated from this one. diff --git a/lib/Config.hs b/lib/Config.hs index 363a068..2349e66 100644 --- a/lib/Config.hs +++ b/lib/Config.hs @@ -1,6 +1,4 @@ -{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE RecordWildCards #-} --- | module Config where import Conferer (DefaultConfig (configDef)) diff --git a/lib/Extrapolation.hs b/lib/Extrapolation.hs index 5adc074..6a2d88a 100644 --- a/lib/Extrapolation.hs +++ b/lib/Extrapolation.hs @@ -1,12 +1,8 @@ -{-# LANGUAGE AllowAmbiguousTypes #-} -{-# LANGUAGE ConstrainedClassMethods #-} -{-# LANGUAGE ConstraintKinds #-} -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE MultiWayIf #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE RecordWildCards #-} module Extrapolation (Extrapolator(..), LinearExtrapolator(..), linearDelay, distanceAlongLine, euclid) where import Data.Foldable (maximumBy, minimumBy) diff --git a/lib/GTFS.hs b/lib/GTFS.hs index a2718b1..6d8bcc5 100644 --- a/lib/GTFS.hs +++ b/lib/GTFS.hs @@ -1,19 +1,11 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE StandaloneKindSignatures #-} -{-# LANGUAGE TupleSections #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE UndecidableInstances #-} -- | All kinds of stuff that has to deal with GTFS directly -- (i.e. parsing, querying, Aeson instances, etc.) diff --git a/lib/Persist.hs b/lib/Persist.hs index a8ed15e..cd77b7a 100644 --- a/lib/Persist.hs +++ b/lib/Persist.hs @@ -1,18 +1,10 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE QuasiQuotes #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE QuasiQuotes #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE UndecidableInstances #-} -- | Data types that are or might yet be saved in the database, and possibly -- also a few little convenience functions for using persistent. diff --git a/lib/Server.hs b/lib/Server.hs index eff1807..016707b 100644 --- a/lib/Server.hs +++ b/lib/Server.hs @@ -1,13 +1,8 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE ExplicitNamespaces #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedLists #-} -{-# LANGUAGE PartialTypeSignatures #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE OverloadedLists #-} +{-# LANGUAGE RecordWildCards #-} -- Implementation of the API. This module is the main point of the program. diff --git a/lib/Server/ControlRoom.hs b/lib/Server/ControlRoom.hs index 402f0b8..773468a 100644 --- a/lib/Server/ControlRoom.hs +++ b/lib/Server/ControlRoom.hs @@ -1,19 +1,12 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeOperators #-} module Server.ControlRoom (ControlRoom(..)) where diff --git a/lib/Server/GTFS_RT.hs b/lib/Server/GTFS_RT.hs index cfb02ce..740f71c 100644 --- a/lib/Server/GTFS_RT.hs +++ b/lib/Server/GTFS_RT.hs @@ -1,9 +1,8 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TupleSections #-} +{-# LANGUAGE DataKinds #-} module Server.GTFS_RT (gtfsRealtimeServer) where diff --git a/lib/Server/Util.hs b/lib/Server/Util.hs index 41d26f7..5ffb829 100644 --- a/lib/Server/Util.hs +++ b/lib/Server/Util.hs @@ -1,7 +1,3 @@ -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE TypeSynonymInstances #-} - -- | mostly the monad the service runs in module Server.Util (Service, ServiceM, runService, sendErrorMsg, secondsNow, utcToSeconds) where diff --git a/tracktrain.cabal b/tracktrain.cabal index e763f6d..f245250 100644 --- a/tracktrain.cabal +++ b/tracktrain.cabal @@ -1,24 +1,15 @@ cabal-version: 2.4 name: tracktrain version: 0.1.0.0 - --- A short (one-line) description of the package. -synopsis: tracktrain tracks trains on their traintracks - --- A longer description of the package. --- description: - --- A URL where users can report bugs. --- bug-reports: - --- The license under which the package is released. --- license: +synopsis: tracktrain tracks trains on their traintracks +description: A passenger information system backend for the Ilztalbahn +license: EUPL-1.2 author: stuebinm maintainer: stuebinm@disroot.org -- A copyright notice. -- copyright: --- category: + extra-source-files: CHANGELOG.md executable tracktrain @@ -43,7 +34,7 @@ executable tracktrain , extra , proto-lens hs-source-dirs: app - default-language: Haskell2010 + default-language: GHC2021 default-extensions: OverloadedStrings , ScopedTypeVariables @@ -118,14 +109,14 @@ library other-modules: Server.Util , Yesod.Auth.Uffd , Yesod.Orphans - default-language: Haskell2010 + default-language: GHC2021 default-extensions: OverloadedStrings , ScopedTypeVariables , ViewPatterns library gtfs-realtime build-depends: base ^>=4.17 - , proto-lens-runtime + , proto-lens-runtime default-language: Haskell2010 hs-source-dirs: gtfs-realtime exposed-modules: Proto.GtfsRealtime -- cgit v1.2.3