Question: Using haskell Problem 3 [35 Points]. Declare a data type MyFraction for handling fractions - where each number is a (numerator, denominator) pair of integers

Using haskell Problem 3 [35 Points]. Declare a data type MyFraction forUsing haskell

Problem 3 [35 Points]. 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 Problem 3 [35 Points]. 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!