Maintainer | hapytexeu+gh@gmail.com |
---|---|
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
The module exposes a GTIN
data type that contains the number of digits as well.
Synopsis
- newtype GTIN (n :: Natural) = GTIN Word64
- gtin :: forall i n. ((<=) n 19, Integral i, KnownNat n) => i -> Maybe (GTIN n)
- type GTIN14 = GTIN 14
- type GTIN13 = GTIN 13
- type GTIN12 = GTIN 12
- type GTIN8 = GTIN 8
- type EANUCC14 = GTIN14
- type SCC14 = GTIN14
- type EAN = GTIN13
- type EANUCC13 = GTIN13
- type ISBN = GTIN13
- type ISBN13 = GTIN13
- type EANUCC8 = GTIN8
- type GSIN = GTIN 17
- type SSCC = GTIN 18
- equivGTIN :: GTIN m -> GTIN n -> Bool
- upscaleGTIN :: (<=) m n => GTIN m -> GTIN n
- fixChecksum :: GTIN n -> GTIN n
- checkChecksum :: GTIN n -> Bool
- gtinToString :: KnownNat n => GTIN n -> String
- fromISBN10' :: Integral i => i -> ISBN13
- gtinParser :: forall s u m n. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s m Char) => ParsecT s u m (GTIN n)
- gtinParser_ :: forall s u m n. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s m Char) => ParsecT s u m (GTIN n)
- gtinParser' :: forall s u m n. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s m Char) => ParsecT s u m (GTIN n)
- gtinParser_' :: forall s u m n. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s m Char) => ParsecT s u m (GTIN n)
- parseGTIN :: forall n s. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s Identity Char) => s -> Either ParseError (GTIN n)
- parseGTIN_ :: forall n s. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s Identity Char) => s -> Either ParseError (GTIN n)
- parseGTIN' :: forall n s. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s Identity Char) => s -> Either ParseError (GTIN n)
- parseGTIN_' :: forall n s. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s Identity Char) => s -> Either ParseError (GTIN n)
- gtinQ :: forall n. ((<=) 2 n, (<=) n 19, KnownNat n) => Proxy (GTIN n) -> QuasiQuoter
- gtin14Q :: QuasiQuoter
- gtin13Q :: QuasiQuoter
- gtin12Q :: QuasiQuoter
- gtin8Q :: QuasiQuoter
- eanucc8Q :: QuasiQuoter
- eanucc14Q :: QuasiQuoter
- scc14Q :: QuasiQuoter
- eanQ :: QuasiQuoter
- eanucc13Q :: QuasiQuoter
- gsinQ :: QuasiQuoter
- ssccQ :: QuasiQuoter
- isbnQ :: QuasiQuoter
- isbn13Q :: QuasiQuoter
GTIN and its aliasses.
newtype GTIN (n :: Natural) Source #
A datatype for Global Trade Item Numbers GTIN
with arbitrary "width" (up to nineteen digits technically possible).
Instances
Lift (GTIN n :: Type) Source # | |
(n <= 19, KnownNat n) => Arbitrary (GTIN n) Source # | |
KnownNat n => Data (GTIN n) Source # | |
Defined in Data.Trade.GTIN gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GTIN n -> c (GTIN n) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (GTIN n) # toConstr :: GTIN n -> Constr # dataTypeOf :: GTIN n -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (GTIN n)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GTIN n)) # gmapT :: (forall b. Data b => b -> b) -> GTIN n -> GTIN n # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GTIN n -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GTIN n -> r # gmapQ :: (forall d. Data d => d -> u) -> GTIN n -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> GTIN n -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> GTIN n -> m (GTIN n) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GTIN n -> m (GTIN n) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GTIN n -> m (GTIN n) # | |
KnownNat n => Bounded (GTIN n) Source # | |
KnownNat n => Enum (GTIN n) Source # | |
Defined in Data.Trade.GTIN | |
Generic (GTIN n) Source # | |
(n <= 19, KnownNat n) => Num (GTIN n) Source # | |
Read (GTIN n) Source # | |
(n <= 19, KnownNat n) => Integral (GTIN n) Source # | |
(n <= 19, KnownNat n) => Real (GTIN n) Source # | |
Defined in Data.Trade.GTIN toRational :: GTIN n -> Rational # | |
KnownNat n => Show (GTIN n) Source # | |
Binary (GTIN n) Source # | |
Eq (GTIN n) Source # | |
Ord (GTIN n) Source # | |
Hashable (GTIN n) Source # | |
Defined in Data.Trade.GTIN | |
KnownNat n => Validity (GTIN n) Source # | |
Defined in Data.Trade.GTIN validate :: GTIN n -> Validation # | |
type Rep (GTIN n) Source # | |
Defined in Data.Trade.GTIN |
:: forall i n. ((<=) n 19, Integral i, KnownNat n) | |
=> i | An |
-> Maybe (GTIN n) | A |
Constructing a 'GTIN" with bound and checksum checks.
type GTIN14 = GTIN 14 Source #
A type alias for a GTIN
number with fourteen numbers, with as range 00 0000 0000 0000
–99 9999 9999 9997
.
type GTIN13 = GTIN 13 Source #
A type alias for a GTIN
number with thirteen numbers, with as range 0 0000 0000 0000
–9 9999 9999 9994
.
type GTIN12 = GTIN 12 Source #
A type alias for a GTIN
number with twelve numbers, with as range 0000 0000 0000
–9999 9999 9993
.
A type alias for a GTIN
number with eight numbers, with as range 0000 0000
–9999 9995
.
type EANUCC14 = GTIN14 Source #
A type alias for a GTIN
number with fourteen numbers, with as range 00 0000 0000 0000
–99 9999 9999 9997
.
A type alias for a GTIN
number with fourteen numbers, with as range 00 0000 0000 0000
–99 9999 9999 9997
.
A type alias for a GTIN
number with thirteen numbers, with as range 0 0000 0000 0000
–9 9999 9999 9994
.
type EANUCC13 = GTIN13 Source #
A type alias for a GTIN
number with thirteen numbers, with as range 0 0000 0000 0000
–9 9999 9999 9994
.
A type alias for a GTIN
with thirtheen numbers which is also an ISBN number, with as range 0 0000 0000 0000
–9 9999 9999 9994
.
A type alias for a GTIN
with thirtheen numbers which is also an ISBN number, with as range 0 0000 0000 0000
–9 9999 9999 9994
.
A type alias for a GTIN
number with eight numbers, with as range 0000 0000
–9999 9995
.
A type alias for a GTIN
number with seventeen numbers, with as range 0 0000 0000 0000 0000
–9 9999 9999 9999 9992
.
A type alias for a GTIN
number with eighteen numbers, with as range 00 0000 0000 0000 0000
–99 9999 9999 9999 9995
.
Check if two GTINs are equivalent, even if the "width" of the GTINs are equivalent.
:: GTIN m | The first |
-> GTIN n | The second |
-> Bool |
|
Check if two GTIN
numbers, possibly with a different "width" are equivalent.
Fix the checksum of a GTIN number
:: GTIN n | The given |
-> GTIN n | A |
Fix the checksum of a given GTIN
object. If the checksum is valid, then it will return the same GTIN, this operation is thus idempotent.
Check if the given checksum matches.
Convert the GTINs to a readable format.
ISBN-10 to ISBN-13
:: Integral i | |
=> i | An |
-> ISBN13 | The equivalent ISBN-13 number, which is a |
Convert a given integral number that contains an ISBN-10 number into the ISBN13
equivalent. For example 8175257660
is converted to 9 7881 7525 7665
. This will add a 978
prefix,
and recalculate the checksum.
Parsing GTINs
:: forall s u m n. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s m Char) | |
=> ParsecT s u m (GTIN n) | A parser parsing a GTIN with an arbitrary number of digits that forces the stream to end, and does checks the checksum. |
A parser for a gtin number with an arbitrary number of digits between two and nineteen. the parser forces the stream to end after the gtin, and validates if the gtin is indeed valid. The parser parses the number of digits with an arbitrary number of spaces between any two digits.
:: forall s u m n. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s m Char) | |
=> ParsecT s u m (GTIN n) | A parser parsing a GTIN with an arbitrary number of digits that does not force the stream to end, but checks the checksum. |
A parser for a gtin number with an arbitrary number of digits between two and nineteen. the parser does not end after the gtin (so no eof
is required).
The GTIN is validated, so if the checksum does not match, the parser fails. The parser parses the number of digits with an arbitrary number of spaces between any two digits.
:: forall s u m n. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s m Char) | |
=> ParsecT s u m (GTIN n) | A parser parsing a GTIN with an arbitrary number of digits thats force the stream to end, but does not check the checksum. |
A parser for a gtin number with an arbitrary number of digits between two and nineteen. the parser forces the stream to end after the gtin, but does not validate if the gtin is indeed valid. The parser parses the number of digits with an arbitrary number of spaces between any two digits.
:: forall s u m n. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s m Char) | |
=> ParsecT s u m (GTIN n) | A parser parsing a GTIN with an arbitrary number of digits that does not force the stream to end, and does not check the checksum. |
A parser for a gtin number with an arbitrary number of digits between two and nineteen. the parser does not end after the gtin (so no eof
is required),
and furthermore does not validate if the gtin is indeed valid. The parser parses the number of digits with an arbitrary number of spaces between any two digits.
:: forall n s. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s Identity Char) | |
=> s | The stream to parse. |
-> Either ParseError (GTIN n) | The result of the parser: |
Run the gtinParser_'
parser and thus parses a GTIN
with an arbitrary number of digits. The parser requires the stream to end after the GTIN
, and validates the checksum.
:: forall n s. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s Identity Char) | |
=> s | The stream to parse. |
-> Either ParseError (GTIN n) | The result of the parser: |
Run the gtinParser_'
parser and thus parses a GTIN
with an arbitrary number of digits. The parser does not require the stream to end after the GTIN
, but validates the checksum.
:: forall n s. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s Identity Char) | |
=> s | The stream to parse. |
-> Either ParseError (GTIN n) | The result of the parser: |
Run the gtinParser_'
parser and thus parses a GTIN
with an arbitrary number of digits. The parser requires the stream to end after the GTIN
, but does not validate the checksum.
:: forall n s. ((<=) 2 n, (<=) n 19, KnownNat n, Stream s Identity Char) | |
=> s | The stream to parse. |
-> Either ParseError (GTIN n) | The result of the parser: |
Run the gtinParser_'
parser and thus parses a GTIN
with an arbitrary number of digits. The parser does not require the stream to end after the GTIN
, and does not validate the checksum.
QuasiQuoters
:: forall n. ((<=) 2 n, (<=) n 19, KnownNat n) | |
=> Proxy (GTIN n) | The |
-> QuasiQuoter | The corresponding |
:: QuasiQuoter | The corresponding |
A QuasiQuoter
for an ISBN
number, only the thirteen digit number is supported.