diff options
author | stuebinm | 2022-07-02 00:16:02 +0200 |
---|---|---|
committer | stuebinm | 2022-07-02 00:35:34 +0200 |
commit | 6c25964c0165530e7db6650eea79cbac99031353 (patch) | |
tree | 2b821e5e07320c211a8af0e70974cbbe6defef9e /gtfs/GTFS/Realtime/Alert/Effect.hs | |
parent | 6b4e8ba88f35538d62bb78b9872bc298178cf96d (diff) |
gtfs realtime proof of concept
this adds a package for protobuf stuff, generated via hprotoc. Seems to
work kinda fine?
(the generated API is horrible though, will have to write some wrappers
for that)
Diffstat (limited to 'gtfs/GTFS/Realtime/Alert/Effect.hs')
-rw-r--r-- | gtfs/GTFS/Realtime/Alert/Effect.hs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/gtfs/GTFS/Realtime/Alert/Effect.hs b/gtfs/GTFS/Realtime/Alert/Effect.hs new file mode 100644 index 0000000..dcaa77d --- /dev/null +++ b/gtfs/GTFS/Realtime/Alert/Effect.hs @@ -0,0 +1,114 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.Alert.Effect (Effect(..)) where +import Prelude ((+), (/), (.)) +import qualified Prelude as Prelude' +import qualified Data.List as Prelude' +import qualified Data.Typeable as Prelude' +import qualified GHC.Generics as Prelude' +import qualified Data.Data as Prelude' +import qualified Text.ProtocolBuffers.Header as P' + +data Effect = NO_SERVICE + | REDUCED_SERVICE + | SIGNIFICANT_DELAYS + | DETOUR + | ADDITIONAL_SERVICE + | MODIFIED_SERVICE + | OTHER_EFFECT + | UNKNOWN_EFFECT + | STOP_MOVED + | NO_EFFECT + | ACCESSIBILITY_ISSUE + deriving (Prelude'.Read, Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) + +instance P'.Mergeable Effect + +instance Prelude'.Bounded Effect where + minBound = NO_SERVICE + maxBound = ACCESSIBILITY_ISSUE + +instance P'.Default Effect where + defaultValue = NO_SERVICE + +toMaybe'Enum :: Prelude'.Int -> P'.Maybe Effect +toMaybe'Enum 1 = Prelude'.Just NO_SERVICE +toMaybe'Enum 2 = Prelude'.Just REDUCED_SERVICE +toMaybe'Enum 3 = Prelude'.Just SIGNIFICANT_DELAYS +toMaybe'Enum 4 = Prelude'.Just DETOUR +toMaybe'Enum 5 = Prelude'.Just ADDITIONAL_SERVICE +toMaybe'Enum 6 = Prelude'.Just MODIFIED_SERVICE +toMaybe'Enum 7 = Prelude'.Just OTHER_EFFECT +toMaybe'Enum 8 = Prelude'.Just UNKNOWN_EFFECT +toMaybe'Enum 9 = Prelude'.Just STOP_MOVED +toMaybe'Enum 10 = Prelude'.Just NO_EFFECT +toMaybe'Enum 11 = Prelude'.Just ACCESSIBILITY_ISSUE +toMaybe'Enum _ = Prelude'.Nothing + +instance Prelude'.Enum Effect where + fromEnum NO_SERVICE = 1 + fromEnum REDUCED_SERVICE = 2 + fromEnum SIGNIFICANT_DELAYS = 3 + fromEnum DETOUR = 4 + fromEnum ADDITIONAL_SERVICE = 5 + fromEnum MODIFIED_SERVICE = 6 + fromEnum OTHER_EFFECT = 7 + fromEnum UNKNOWN_EFFECT = 8 + fromEnum STOP_MOVED = 9 + fromEnum NO_EFFECT = 10 + fromEnum ACCESSIBILITY_ISSUE = 11 + toEnum = P'.fromMaybe (Prelude'.error "hprotoc generated code: toEnum failure for type GTFS.Realtime.Alert.Effect") . toMaybe'Enum + succ NO_SERVICE = REDUCED_SERVICE + succ REDUCED_SERVICE = SIGNIFICANT_DELAYS + succ SIGNIFICANT_DELAYS = DETOUR + succ DETOUR = ADDITIONAL_SERVICE + succ ADDITIONAL_SERVICE = MODIFIED_SERVICE + succ MODIFIED_SERVICE = OTHER_EFFECT + succ OTHER_EFFECT = UNKNOWN_EFFECT + succ UNKNOWN_EFFECT = STOP_MOVED + succ STOP_MOVED = NO_EFFECT + succ NO_EFFECT = ACCESSIBILITY_ISSUE + succ _ = Prelude'.error "hprotoc generated code: succ failure for type GTFS.Realtime.Alert.Effect" + pred REDUCED_SERVICE = NO_SERVICE + pred SIGNIFICANT_DELAYS = REDUCED_SERVICE + pred DETOUR = SIGNIFICANT_DELAYS + pred ADDITIONAL_SERVICE = DETOUR + pred MODIFIED_SERVICE = ADDITIONAL_SERVICE + pred OTHER_EFFECT = MODIFIED_SERVICE + pred UNKNOWN_EFFECT = OTHER_EFFECT + pred STOP_MOVED = UNKNOWN_EFFECT + pred NO_EFFECT = STOP_MOVED + pred ACCESSIBILITY_ISSUE = NO_EFFECT + pred _ = Prelude'.error "hprotoc generated code: pred failure for type GTFS.Realtime.Alert.Effect" + +instance P'.Wire Effect where + wireSize ft' enum = P'.wireSize ft' (Prelude'.fromEnum enum) + wirePut ft' enum = P'.wirePut ft' (Prelude'.fromEnum enum) + wireGet 14 = P'.wireGetEnum toMaybe'Enum + wireGet ft' = P'.wireGetErr ft' + wireGetPacked 14 = P'.wireGetPackedEnum toMaybe'Enum + wireGetPacked ft' = P'.wireGetErr ft' + +instance P'.GPB Effect + +instance P'.MessageAPI msg' (msg' -> Effect) Effect where + getVal m' f' = f' m' + +instance P'.ReflectEnum Effect where + reflectEnum + = [(1, "NO_SERVICE", NO_SERVICE), (2, "REDUCED_SERVICE", REDUCED_SERVICE), (3, "SIGNIFICANT_DELAYS", SIGNIFICANT_DELAYS), + (4, "DETOUR", DETOUR), (5, "ADDITIONAL_SERVICE", ADDITIONAL_SERVICE), (6, "MODIFIED_SERVICE", MODIFIED_SERVICE), + (7, "OTHER_EFFECT", OTHER_EFFECT), (8, "UNKNOWN_EFFECT", UNKNOWN_EFFECT), (9, "STOP_MOVED", STOP_MOVED), + (10, "NO_EFFECT", NO_EFFECT), (11, "ACCESSIBILITY_ISSUE", ACCESSIBILITY_ISSUE)] + reflectEnumInfo _ + = P'.EnumInfo (P'.makePNF (P'.pack ".transit_realtime.Alert.Effect") [] ["GTFS", "Realtime", "Alert"] "Effect") + ["GTFS", "Realtime", "Alert", "Effect.hs"] + [(1, "NO_SERVICE"), (2, "REDUCED_SERVICE"), (3, "SIGNIFICANT_DELAYS"), (4, "DETOUR"), (5, "ADDITIONAL_SERVICE"), + (6, "MODIFIED_SERVICE"), (7, "OTHER_EFFECT"), (8, "UNKNOWN_EFFECT"), (9, "STOP_MOVED"), (10, "NO_EFFECT"), + (11, "ACCESSIBILITY_ISSUE")] + Prelude'.False + +instance P'.TextType Effect where + tellT = P'.tellShow + getT = P'.getRead
\ No newline at end of file |