Module 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

Version: 0.0.1

Summary of exported operations:

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

Is a given roman number well formed?

showRoman :: Roman -> String   

Shows roman numbers in the usual way.

showsRoman :: Roman -> String -> String   

Shows roman numbers continuation style.

toInt :: Roman -> Int   

Converts a roman number to an integer.

fromInt :: Int -> Roman   

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