Question

Haskell question, please give an explanation as well.

QUESTION 1 Consider the algebraic type definition: data Foo Bar | Baz Int and the function definition frob Foo->Foo ->Bool fr

0 0
Add a comment Improve this question Transcribed image text
Answer #1

algebraic type definition:

data Foo = Bar | Baz int

The above definition of data  of type integer.

function definition:

frob::Foo->Foo ->Bool

frob(Baz j)(Baz k)=j==k

frob__=False

  • Here the type of data is Int type is an instance and check the equality so use Eq.
  • Eq is mainly used for the == functions with values of that type here the values corresponding to the int.

deriving Eq

Option b

Add a comment
Know the answer?
Add Answer to:
QUESTION 1 Consider the algebraic type definition: data Foo Bar | Baz Int and the function defini...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C -...

    Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C - A consecutive group of memory chunks. D - None of the choices. Question 2 How many times is the body of the loop executed? int i=1; while(true) { cout << i; if(++i==5) break; } A - Forever B - 4 C - 5 D - 6 E - 0 Question 3 What is wrong with the following piece of...

  • This project is divided into 3 parts: Part 1. Create a new project and download the arrayList and...

    This project is divided into 3 parts: Part 1. Create a new project and download the arrayList and unorderedArrayList templates that are attached. Create a header file for your unorderedSet template and add it to the project. An implementation file will not be needed since the the new class will be a template. Override the definitions of insertAt, insertEnd, and replaceAt in the unorderedSet template definition. Implement the template member functions so that all they do is verify that the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT