Portability | portable |
---|---|
Stability | provisional |
Maintainer | jhb@n-sim.com |
An implementation of Luhn's check digit algorithm.
- addLuhnDigit :: Integral n => n -> n
- checkLuhnDigit :: Integral n => n -> Bool
- prop_checkLuhn :: Integer -> Property
- prop_checkSingleError :: Integer -> Integer -> Integer -> Property
Creating a check digit
:: Integral n | |
=> n | Number to which a Luhn check digit will be appended. |
-> n | Number with the appended Luhn check digit. |
Appends a Luhn check digit to the end of a number.
Validating a check digit
:: Integral n | |
=> n | Number with a Luhn check digit as its last digit. |
-> Bool | Whether or not the check digit is consistent. |
Validates that the Luhn check digit (assumed to be the last/least- significant digit in the number) is correct.
QuickCheck tests
Validates that a generated check digit validates.
:: Integer | The number to transcribe. |
-> Integer | The position to introduce a transcription error. |
-> Integer | The number to transcribe in place of the original. |
-> Property |
Any single number transcription error should result in a failure in the validation of a Luhn check digit. This property validates this.