Reference no: EM132234287
The programming language is HASKELL.
Problem - Declare a data type MyFraction- for handling fractions -- where each number is a (numerator, denominator) pair of integers representing the numerator and the denominator of the fraction.
For example, (22, 23) would represent 22 / 23. The numerator can be positive or negative, and the denominator must always be positive.
Carefully pick Haskell's built-in type classes which this type should be an instance of.
You should define - and when meaningful overload - simple arithmetic and comparison operations on these fractions (at least: *, /, +, -, neg (negation), <=, >=, <, >, ==).
Also define functions numerator and denominator to return the numerator and denominator, and functions whole and fractional to extract the whole and the fractional part of the fraction.
For example, for (23, 22), whole should return 1, and fraction should return 1 / 22. Function fractional should return a MyFraction data type.