Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type FitParser a = StateT FpState Parser a
- runFitParser :: FitParser a -> Parser a
- data FpState = FpState {
- _fpArch :: !Arch
- _fpMessageDefs :: Definitions
- _fpLastTimestamp :: !(Maybe Timestamp)
- newtype Definitions = Defs {}
- addMessageDef :: MessageDefinition -> FitParser ()
- lookupMessageDef :: LocalMessageType -> FitParser MessageDefinition
- withArchitecture :: Arch -> FitParser a -> FitParser a
- storeTimestamp :: Timestamp -> FitParser ()
- updateTimestamp :: TimeOffset -> FitParser Timestamp
- word8 :: FitParser Word8
- int8 :: FitParser Int8
- archWord16 :: FitParser Word16
- archWord32 :: FitParser Word32
- archWord64 :: FitParser Word64
- archInt16 :: FitParser Int16
- archInt32 :: FitParser Int32
- archInt64 :: FitParser Int64
- archFloat32 :: FitParser Float
- archFloat64 :: FitParser Double
FitParser
runFitParser :: FitParser a -> Parser a Source
The necessary state for parsing FIT files
FpState | |
|
newtype Definitions Source
The definitions are stored as a map on the local message type number. When a definition is parsed with a previously-used local message type, the previous definition is overwritten.
addMessageDef :: MessageDefinition -> FitParser () Source
Register a MessageDefinition
with the parser, so it can decode
subsequent data messages using the definition
lookupMessageDef :: LocalMessageType -> FitParser MessageDefinition Source
Look up the MessageDefinition
for the given message type.
It is an error to look up a message type that has no registered definition,
since it is impossible to decode a data message with no definition
withArchitecture :: Arch -> FitParser a -> FitParser a Source
Little-endian interpretation is used by default by FitParser
.
Use this function to set the endianness to use for the scope of a particular action.
After the action is finished the previous endianness is restored.
storeTimestamp :: Timestamp -> FitParser () Source
Store the given Timestamp
as the most recent. Is used to store timestamps
from non-compressed timestamp messages. For compressed-timestamp messages use
updateTimestamp
instead.
updateTimestamp :: TimeOffset -> FitParser Timestamp Source
Use the given TimeOffset
and the previous Timestamp
to compute a new
Timestamp. The new Timestamp
is stored as most recent and is returned.
This function fails if there is no previously-stored Timestamp
. This
condition should never come up when parsing a valid FIT file.
Architecture-independent parsers
Architecture-dependent parsers
The following parsers are all sensitive to the active endianness. For example,
archWord16
will use a little-endian or big-endian interpretation according
to the architecture for the MessageDefinition
for the current message.
Internally, these parsers use the endian-specific parsers from Fit.Internal.Numbers.
archWord16 :: FitParser Word16 Source
Parse a Word16 using the active endianness
archWord32 :: FitParser Word32 Source
Parse a Word32 using the active endianness
archWord64 :: FitParser Word64 Source
Parse a Word64 using the active endianness
archFloat32 :: FitParser Float Source
Parse a Float using the active endianness
archFloat64 :: FitParser Double Source
Parse a Double using the active endianness