roc-id-0.1.0.0: Implementation of the ROC National ID standard.

Safe HaskellNone
LanguageHaskell2010

ROC.ID

Synopsis

Documentation

data Identity Source #

Represents a valid 10-digit ROC national identification number (中華民國身份證號碼) of the form A123456789.

By construction, invalid values are not representable by this type.

An identification number encodes a person's Gender, the Location in which they first registered for an identification card, and a unique Serial number.

Constructors

Identity 

Fields

Instances
Eq Identity Source # 
Instance details

Defined in ROC.ID

Ord Identity Source # 
Instance details

Defined in ROC.ID

Show Identity Source # 
Instance details

Defined in ROC.ID

Generic Identity Source # 
Instance details

Defined in ROC.ID

Associated Types

type Rep Identity :: Type -> Type #

Methods

from :: Identity -> Rep Identity x #

to :: Rep Identity x -> Identity #

type Rep Identity Source # 
Instance details

Defined in ROC.ID

type Rep Identity = D1 (MetaData "Identity" "ROC.ID" "roc-id-0.1.0.0-EBt7nY1QCMq7lYvcqKJOx6" False) (C1 (MetaCons "Identity" PrefixI True) (S1 (MetaSel (Just "identityGender") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Gender) :*: (S1 (MetaSel (Just "identityLocation") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Location) :*: S1 (MetaSel (Just "identitySerial") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Serial))))

identityChecksum :: Identity -> Digit Source #

Calculate the checksum of the specified Identity.

parseIdentity :: Text -> Either ParseError Identity Source #

Attempt to parse an Identity using the specified Text as input.

The input must be of the form A123456789.

data ParseError Source #

An error produced when parsing an Identity with the parseIdentity function.

Constructors

InvalidLength

The input was either too short or too long.

InvalidGender

The gender portion of the input was invalid.

InvalidLocation

The location portion of the input included non-alphabetic characters.

InvalidSerial

The serial number portion of the input included non-numeric characters.

InvalidChecksum

The computed checksum did not match the checksum portion of the input.

Instances
Eq ParseError Source # 
Instance details

Defined in ROC.ID

Show ParseError Source # 
Instance details

Defined in ROC.ID

randomIdentity :: MonadRandom m => m Identity Source #

Generate a random Identity.