diff options
Diffstat (limited to 'lib/GTFS.hs')
-rw-r--r-- | lib/GTFS.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/GTFS.hs b/lib/GTFS.hs index 68d92dc..cf4c939 100644 --- a/lib/GTFS.hs +++ b/lib/GTFS.hs @@ -19,7 +19,6 @@ -- (i.e. parsing, querying, Aeson instances, etc.) module GTFS where - import qualified Codec.Archive.Zip as Zip import Control.Monad.ST (runST) import Data.Aeson (FromJSON, @@ -48,6 +47,8 @@ import qualified Data.Vector.Algorithms.Intro as V import Fmt ((+|), (|+)) import GHC.Generics (Generic) import Text.Regex.TDFA ((=~)) +import Web.Internal.FormUrlEncoded (FromForm (..)) +import Web.Internal.HttpApiData (FromHttpApiData (..)) -- import Data.Aeson.Generic (Options(fieldLabelModifier), deriveJSON, defaultOptions) import Control.Lens import Data.Char (toLower) @@ -178,6 +179,12 @@ data Calendar = Calendar data CalendarExceptionType = ServiceAdded | ServiceRemoved deriving (Show, Eq, Generic, ToJSON, FromJSON) +instance FromHttpApiData CalendarExceptionType where + parseUrlPiece = \case + "added" -> Right ServiceAdded + "removed" -> Right ServiceRemoved + unknown -> Left ("unknown CalendarExceptionType: "<>unknown) + data CalendarDate = CalendarDate { caldateServiceId :: Text , caldateDate :: Day @@ -188,6 +195,7 @@ instance FromJSON CalendarDate where parseJSON = genericParseJSON (aesonOptions "caldate") instance ToJSON CalendarDate where toJSON = genericToJSON (aesonOptions "caldate") +instance FromForm CalendarDate data Trip (deep :: Depth) (shape :: Depth)= Trip { tripRoute :: Text |