Module Data.Roman

Library for roman numbers. This library defines a datatype Roman to represent roman numbers, conversion operations fromInt and toInt to convert integers into roman numbers and back, and an operation showRoman to show roman numbers as strings.

Author: Bernd Brassel, Michael Hanus

Summary of exported operations:

regular :: Roman -> Bool  Deterministic 
Is a given roman number well formed?
showRoman :: Roman -> String  Deterministic 
Shows roman numbers in the usual way.
showsRoman :: Roman -> String -> String  Deterministic 
Shows roman numbers continuation style.
toInt :: Roman -> Int  Deterministic 
Converts a roman number to an integer.
fromInt :: Int -> Roman  Deterministic 
Converts integers to roman numbers.

Exported datatypes:


Roman

The type to represent roman numbers. Examples:

"IV"   =  Minus I V
"III"  =  Plus I (Plus I I)

Constructors:

  • I :: Roman
  • V :: Roman
  • X :: Roman
  • L :: Roman
  • C :: Roman
  • D :: Roman
  • M :: Roman
  • Minus :: Roman -> Roman -> Roman
  • Plus :: Roman -> Roman -> Roman

Exported operations:

regular :: Roman -> Bool  Deterministic 

Is a given roman number well formed?

showRoman :: Roman -> String  Deterministic 

Shows roman numbers in the usual way.

showsRoman :: Roman -> String -> String  Deterministic 

Shows roman numbers continuation style.

toInt :: Roman -> Int  Deterministic 

Converts a roman number to an integer.

fromInt :: Int -> Roman  Deterministic 

Converts integers to roman numbers. Since we have no over/underlining, we can only represent positive integers which are smaller than 4000.