Module ReadNumeric

Library with some functions for reading and converting numeric tokens.

Author: Michael Hanus, Frank Huch, Bjoern Peemoeller

Version: November 2016

Summary of exported operations:

readInt :: String -> Maybe (Int,String)   
Read a (possibly negative) integer as a first token in a string.
readNat :: String -> Maybe (Int,String)   
Read a natural number as a first token in a string.
readHex :: String -> Maybe (Int,String)   
Read a hexadecimal number as a first token in a string.
readOct :: String -> Maybe (Int,String)   
Read an octal number as a first token in a string.
readBin :: String -> Maybe (Int,String)   
Read a binary number as a first token in a string.

Exported operations:

readInt :: String -> Maybe (Int,String)   

Read a (possibly negative) integer as a first token in a string. The string might contain leadings blanks and the integer is read up to the first non-digit. If the string does not start with an integer token, Nothing is returned, otherwise the result is Just (v, s), where v is the value of the integer and s is the remaing string without the integer token.

readNat :: String -> Maybe (Int,String)   

Read a natural number as a first token in a string. The string might contain leadings blanks and the number is read up to the first non-digit. If the string does not start with a natural number token, Nothing is returned, otherwise the result is Just (v, s) where v is the value of the number and s is the remaing string without the number token.

readHex :: String -> Maybe (Int,String)   

Read a hexadecimal number as a first token in a string. The string might contain leadings blanks and the number is read up to the first non-hexadecimal digit. If the string does not start with a hexadecimal number token, Nothing is returned, otherwise the result is Just (v, s) where v is the value of the number and s is the remaing string without the number token.

readOct :: String -> Maybe (Int,String)   

Read an octal number as a first token in a string. The string might contain leadings blanks and the number is read up to the first non-octal digit. If the string does not start with an octal number token, Nothing is returned, otherwise the result is Just (v, s) where v is the value of the number and s is the remaing string without the number token.

readBin :: String -> Maybe (Int,String)   

Read a binary number as a first token in a string. The string might contain leadings blanks and the number is read up to the first non-binary digit. If the string does not start with a binary number token, Nothing is returned, otherwise the result is Just (v, s) where v is the value of the number and s is the remaing string without the number token.