fit-0.5: FIT file decoder

Safe HaskellNone





runFitParser :: FitParser a -> Parser a Source

Turn a FitParser into a plain attoparsec Parser. This doesn't require any configuration as the initial state for a FIT parse is always the same.

data FpState Source

The necessary state for parsing FIT files




_fpArch :: !Arch

The active endian-ness

_fpMessageDefs :: Definitions

The set of active message definitions

_fpLastTimestamp :: !(Maybe Timestamp)

The most recently stored timestamp

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

archInt16 :: FitParser Int16 Source

Parse an Int16 using the active endianness

archInt32 :: FitParser Int32 Source

Parse an Int32 using the active endiannessa

archInt64 :: FitParser Int64 Source

Parse an Int64 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