Copyright | (c) Target RWE 2023 |
---|---|
License | BSD3 |
Maintainer | bbrown@targetrwe.com ljackman@targetrwe.com dpritchard@targetrwe.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
EventDataTheory.EventLines
Contents
Description
Synopsis
- data EventLine t m a = MkEventLine Value Value Value Value [t] (FactsLine m a)
- type EventLineAble t m a b = (Generic m, Typeable m, Typeable t, Typeable a, SizedIv (Interval a))
- parseEventLinesL' :: forall m t a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a) => ParseEventLineOption -> ByteString -> ([LineParseError], [(SubjectID, Event t m a)])
- eitherDecodeEvent' :: forall m t a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a) => ParseEventLineOption -> ByteString -> Either String (SubjectID, Event t m a)
- decodeEvent' :: forall m t a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a) => ParseEventLineOption -> ByteString -> Maybe (SubjectID, Event t m a)
- newtype LineParseError = MkLineParseError (Natural, String)
- data ParseEventLineOption
- defaultParseEventLineOption :: ParseEventLineOption
- modifyEventLineWithContext :: forall m m' t t' a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a, Eventable t' m' a, Data m') => ParseEventLineOption -> (Context t m -> Context t' m') -> ByteString -> Either String (EventLine t' m' a)
- data FactsLine m a = MkFactsLine {}
- data TimeLine a = MkTimeLine {}
Documentation
At this time,
EventLine
, FactsLine
, and TimeLine
are
simply wrapper types
in order to create FromJSON
instances which can be used to marshal data from
ndjson.
Constructors
MkEventLine Value Value Value Value [t] (FactsLine m a) |
Instances
type EventLineAble t m a b = (Generic m, Typeable m, Typeable t, Typeable a, SizedIv (Interval a)) Source #
A synonym for the basic class constraints needed to create an EventLine
.
parseEventLinesL' :: forall m t a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a) => ParseEventLineOption -> ByteString -> ([LineParseError], [(SubjectID, Event t m a)]) Source #
Parse Event t m a
from new-line delimited JSON.
Per the aeson docs, when using this version: This is a strict version of json which avoids building up thunks during parsing; it performs all conversions immediately. Prefer this version if most of the JSON data needs to be accessed.
Returns a pair where the first element is a list of parse errors and the second element is a list of successfully parsed (subjectID, event) pairs.
Note the input must be UTF-8.
eitherDecodeEvent' :: forall m t a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a) => ParseEventLineOption -> ByteString -> Either String (SubjectID, Event t m a) Source #
Decode a bytestring corresponding to an EventLine
into
Either String (SubjectID, Event t m a)
,
where the String
is an error message on failure
and (SubjectID, Event t m a)
is the success case.
NOTE: See https://hackage.haskell.org/package/aeson-2.0.3.0/docs/Data-Aeson.html#g:22 for discusson of json vs json'.
decodeEvent' :: forall m t a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a) => ParseEventLineOption -> ByteString -> Maybe (SubjectID, Event t m a) Source #
Decode a bytestring corresponding to an EventLine
into
Maybe (SubjectID, Event t m a)
,
where the value is Nothing
on failure
and Just (SubjectID, Event t m a)
on success.
NOTE: See https://hackage.haskell.org/package/aeson-2.0.3.0/docs/Data-Aeson.html#g:22 for discusson of json vs json'.
newtype LineParseError Source #
Contains the line number and error message of any parsing errors.
Constructors
MkLineParseError (Natural, String) |
Instances
data ParseEventLineOption Source #
Constructors
AddMomentToEnd | Add a It does not modify intervals for which the provided end is null,
which will fail to parse. See |
DoNotModifyTime | Do not modify the |
FixEnd | Convert |
AddMomentAndFix | Apply fixes from both |
Instances
Show ParseEventLineOption Source # | |
Defined in EventDataTheory.EventLines Methods showsPrec :: Int -> ParseEventLineOption -> ShowS # show :: ParseEventLineOption -> String # showList :: [ParseEventLineOption] -> ShowS # | |
(SizedIv (Interval a), Eventable t m a) => TryFrom (EventLine t m a, ParseEventLineOption) (Event t m a) Source # | Try to parse an |
Defined in EventDataTheory.EventLines Methods tryFrom :: (EventLine t m a, ParseEventLineOption) -> Either (TryFromException (EventLine t m a, ParseEventLineOption) (Event t m a)) (Event t m a) |
defaultParseEventLineOption :: ParseEventLineOption Source #
The default ParseEventLineOption
.
modifyEventLineWithContext :: forall m m' t t' a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a, Eventable t' m' a, Data m') => ParseEventLineOption -> (Context t m -> Context t' m') -> ByteString -> Either String (EventLine t' m' a) Source #
This function:
- parses a JSON bytestring into an
EventLine
- modifies the data in the
EventLine
that corresponds to anEvent
Context
using the supplied function
The function may fail and return an error message
if either the JSON parsing fails
or the EventLine
-> Event
tranformation fails.
This function does not modify the time information in the EventLine
,
nor any of the first four elements of the EventLine
.
See modifyEventLineWithEvent
for a function that can also modify the interval.
See EventLine
.
Constructors
MkFactsLine | |
Instances
See EventLine
.
Constructors
MkTimeLine | |
Instances
FromJSON a => FromJSON (TimeLine a) Source # | |
Defined in EventDataTheory.EventLines | |
ToJSON a => ToJSON (TimeLine a) Source # | |
Defined in EventDataTheory.EventLines Methods toEncoding :: TimeLine a -> Encoding toJSONList :: [TimeLine a] -> Value toEncodingList :: [TimeLine a] -> Encoding | |
Show a => Show (TimeLine a) Source # | |
Eq a => Eq (TimeLine a) Source # | |
Orphan instances
Exception ParseErrorInterval Source # | |
Methods toException :: ParseErrorInterval -> SomeException # fromException :: SomeException -> Maybe ParseErrorInterval # displayException :: ParseErrorInterval -> String # |