luhn-0.2: An implementation of Luhn's check digit algorithm.

Portabilityportable
Stabilityprovisional
Maintainerjhb@n-sim.com

Luhn

Contents

Description

An implementation of Luhn's check digit algorithm.

Synopsis

Creating a check digit

addLuhnDigitSource

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

checkLuhnDigitSource

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_checkLuhnSource

Arguments

:: Integer

Number to validate a Luhn check digit for.

-> Property 

Validates that a generated check digit validates.

prop_checkSingleErrorSource

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.