| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Data.PhoneNumber.LowLevel
Description
Low level phone number handling, more closely matches the underlying libphonenumber API.
- data PhoneNumber = PhoneNumber {}
- data PhoneNumberRef = PhoneNumberRef {}
- data PhoneNumberParseError = PhoneNumberParseError Int
- data PhoneNumberUtil = PhoneNumberUtil {}
- data PhoneNumberType
- getPhoneNumberUtil :: IO PhoneNumberUtil
- newPhoneNumberRef :: IO PhoneNumberRef
- parsePhoneNumber :: PhoneNumberUtil -> PhoneNumberRef -> ByteString -> ByteString -> IO (Either PhoneNumberParseError ())
- unsafeConvertAlphaCharacters :: PhoneNumberUtil -> ByteString -> IO ()
- copyPhoneNumberRef :: PhoneNumberRef -> IO PhoneNumber
- getCountryCode :: PhoneNumberRef -> IO (Maybe Word64)
- getNationalNumber :: PhoneNumberRef -> IO (Maybe Word64)
- getExtension :: PhoneNumberRef -> IO (Maybe ByteString)
- getType :: PhoneNumberUtil -> PhoneNumberRef -> IO PhoneNumberType
Data types
data PhoneNumber Source
A data type representation of a phone number, you can build one of these with copyPhoneNumberRef.
Constructors
| PhoneNumber | |
Fields | |
Instances
data PhoneNumberRef Source
An opaque pointer to a PhoneNumberRef C++ class
Constructors
| PhoneNumberRef | |
Fields | |
Instances
data PhoneNumberParseError Source
There was a problem parting your phone number. For now, if you want to know what the Int here means, you'll need to look at the ErrorType enum in the underlying library.
Constructors
| PhoneNumberParseError Int |
data PhoneNumberUtil Source
An opaque pointer to the (singleton) PhoneNumberUtil C++ class
Constructors
| PhoneNumberUtil | |
Fields | |
Instances
data PhoneNumberType Source
References and parsing
getPhoneNumberUtil :: IO PhoneNumberUtil Source
Grab the singleton PhoneNumberUtil class instance, needed to do useful things with libphonenumber
newPhoneNumberRef :: IO PhoneNumberRef Source
Create a mutable reference to a PhoneNumber (C++ class) instance.
Arguments
| :: PhoneNumberUtil | The singleton PhoneNumberUtil reference |
| -> PhoneNumberRef | The reference to be mutably updated |
| -> ByteString | The bytestring to parse as a phone number |
| -> ByteString | The default region to assume numbers are from, if ambiguous. e.g. AU for Australia |
| -> IO (Either PhoneNumberParseError ()) |
Parse a phone number.
Utility
unsafeConvertAlphaCharacters :: PhoneNumberUtil -> ByteString -> IO () Source
Convert any alpha characters in a phone number to their equivalent keypad numbers.
This modifies the ByteString in place.
Extracting usable information
copyPhoneNumberRef :: PhoneNumberRef -> IO PhoneNumber Source
Copy fields from a PhoneNumberRef and create a PhoneNumber
getCountryCode :: PhoneNumberRef -> IO (Maybe Word64) Source
Read the country code from a PhoneNumberRef
getNationalNumber :: PhoneNumberRef -> IO (Maybe Word64) Source
Read the national number (the phone number itself) from a PhoneNumberRef
getExtension :: PhoneNumberRef -> IO (Maybe ByteString) Source
Read the extension (e.g. 12345678x123) from a PhoneNumberRef