| Maintainer | hapytexeu+gh@gmail.com |
|---|---|
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Finance.Belgium.StructuredCommunication
Description
Belgian companies often make use of structured communication with a checksum. This package aims to provide a toolkit to parse, render and manipulate StructuredCommunication.
Synopsis
- data StructuredCommunication = StructuredCommunication !Word16 !Word16 !Word32
- structuredCommunication :: (Integral i, Integral j, Integral k) => i -> j -> k -> Maybe StructuredCommunication
- checksum :: StructuredCommunication -> Word32
- determineChecksum :: StructuredCommunication -> Word32
- validChecksum :: StructuredCommunication -> Bool
- fixChecksum :: StructuredCommunication -> StructuredCommunication
- communicationToString :: StructuredCommunication -> String
- communicationToText :: StructuredCommunication -> Text
- communicationParser :: Stream s m Char => ParsecT s u m StructuredCommunication
- communicationParser' :: Stream s m Char => ParsecT s u m StructuredCommunication
- communicationEParser :: Stream s m Char => ParsecT s u m StructuredCommunication
- communicationEParser' :: Stream s m Char => ParsecT s u m StructuredCommunication
- parseCommunication :: Stream s Identity Char => s -> Either ParseError StructuredCommunication
- parseCommunication' :: Stream s Identity Char => s -> Either ParseError StructuredCommunication
- parseCommunicationE :: Stream s Identity Char => s -> Either ParseError StructuredCommunication
- parseCommunicationE' :: Stream s Identity Char => s -> Either ParseError StructuredCommunication
- beCommunication :: QuasiQuoter
Constructing StructuredCommunication
data StructuredCommunication Source #
A data type that stores three numbers: one with three digits (000–999), four digits (0000–9999) and five digits (00001–99997). The data
constructor itself is not accessible, since the StructuredCommunication could produce objects that are out of the given ranges, or where the
checksum is not valid. The module thus aims to prevent parsing, changing, etc. StructuredCommunication objects into an invalid state.
Constructors
| StructuredCommunication !Word16 !Word16 !Word32 |
Instances
structuredCommunication Source #
Arguments
| :: (Integral i, Integral j, Integral k) | |
| => i | The first number, should be between |
| -> j | The second number, should be between |
| -> k | The third number, should be between |
| -> Maybe StructuredCommunication | The |
Construct a StructuredCommunication object for the given three integral values that form the three sequences of digits.
determining the checksum
Arguments
| :: StructuredCommunication | The |
| -> Word32 | The last two digits of the |
Determining the checksum-part for the given StructuredCommunication. This thus takes the last two digits, or the third number modulo one hundred.
Arguments
| :: StructuredCommunication | The |
| -> Word32 | The checksum determined by the first ten digits, not per se the real checksum of the |
Determine the checksum based on the first ten digits. If the StructuredCommunication is not valid, its checksum will not match the result of the determineChecksum.
Arguments
| :: StructuredCommunication | The |
| -> Bool |
Check if the checksum matches for the given StructuredCommunication.
Arguments
| :: StructuredCommunication | The given |
| -> StructuredCommunication | A variant of the given |
Convert the given StructuredCommunication to one where the checksum is valid. If the checksum was already valid, it returns an equivalent
StructuredCommunication, this operation is thus idempotent.
Converting to text
communicationToString Source #
Arguments
| :: StructuredCommunication | The given |
| -> String | The corresponding |
Convert the given StructuredCommunication to a String that looks like a structured communication, so +++000/0000/00097+++.
Arguments
| :: StructuredCommunication | The given |
| -> Text | The corresponding |
Convert the given StructuredCommunication to a Text that looks like a structured communication, so +++000/0000/00097+++.
Parsing from text
Arguments
| :: Stream s m Char | |
| => ParsecT s u m StructuredCommunication | The |
A ParsecT that parses a string into a StructuredCommunication, the StructuredCommunication is checked for its validity (checksum). The parser does not (per se) ends with an eof.
Arguments
| :: Stream s m Char | |
| => ParsecT s u m StructuredCommunication | The |
A ParsecT that parses a string into a StructuredCommunication, the StructuredCommunication can be invalid. The parser also does not (per se) ends with an eof.
Arguments
| :: Stream s m Char | |
| => ParsecT s u m StructuredCommunication | The |
A ParsecT that parses a string into a StructuredCommunication, the StructuredCommunication is checked for its validity (checksum). The parser also checks that this is the end of the stream.
communicationEParser' Source #
Arguments
| :: Stream s m Char | |
| => ParsecT s u m StructuredCommunication | The |
A ParsecT that parses a string into a StructuredCommunication, the StructuredCommunication can be invalid. The parser also checks if this is the end of the stream.
Arguments
| :: Stream s Identity Char | |
| => s | The stream that is parsed into a |
| -> Either ParseError StructuredCommunication | The result of parsing, either a |
Parsing a stream into a StructuredCommunication that also validates the checksum of the communication. The stream does not per se needs to end with structured communcation.
Arguments
| :: Stream s Identity Char | |
| => s | The stream that is parsed into a |
| -> Either ParseError StructuredCommunication | The result of parsing, either a |
Parsing a stream into a StructuredCommunication that does noet validate the checksum of the communication. The stream does not per se needs to end with structured communcation.
Arguments
| :: Stream s Identity Char | |
| => s | The stream that is parsed into a |
| -> Either ParseError StructuredCommunication | The result of parsing, either a |
Parsing a stream into a StructuredCommunication that also validates the checksum of the communication. After the structured communication, the stream needs to end.
Arguments
| :: Stream s Identity Char | |
| => s | The stream that is parsed into a |
| -> Either ParseError StructuredCommunication | The result of parsing, either a |
Parsing a stream into a StructuredCommunication that does noet validate the checksum of the communication. After the structured communication, the stream needs to end.
Quasi quotation
Arguments
| :: QuasiQuoter | A |
A QuasiQuoter that can parse a string into an expression or pattern. It will thus convert +++000/000/00097+++ into a StructuredCommunication as expression or pattern.