luhn-0.3: An implementation of Luhn's check digit algorithm.
Copyright(c) N-Sim Ltd. 2008
LicenseBSD3
Maintainerjhb@n-sim.com
Stabilityprovisional
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Luhn

Description

An implementation of Luhn's check digit algorithm.

Synopsis

Creating a check digit

addLuhnDigit Source #

Arguments

:: 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

checkLuhnDigit Source #

Arguments

:: 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

prop_checkLuhn Source #

Arguments

:: Integer

Number to validate a Luhn check digit for.

-> Property 

Validates that a generated check digit validates.

prop_checkSingleError Source #

Arguments

:: 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.