Question

Haskell coding problem please do problem two

Problem Two (Polymorphic Type Inference): Give the type of the following functions in the space indicated. Assume that we hav

Here is problem one for the types

Problem One (Non-Polymorphic Type Inference): Give the type of the following expressions. We assume that we can have Integer

Problem Two (Polymorphic Type Inference): Give the type of the following functions in the space indicated. Assume that we have only the types given in Problem One, plus Haskell's built-in types Integer and Bool. Assume that all arithmetic operators take only Integer, e.g., () is Integer -> Integer -> Integer. test :: test x xs = (Cons x (Cons (x+1) xs)) second second xs = f (g xs) where f (Cons x _) - x pair pair xy=P(y x) y twice :: twice f x f (f x) apply: apply f g xf (g x) mixUp :: mixUp f g -> f ((g. ) x) peculiar :: peculiar x (P y z) = (P (x y) (x z))
Problem One (Non-Polymorphic Type Inference): Give the type of the following expressions. We assume that we can have Integer and Bools as defined in the Haskell Prelude. Assume that all arithmetic operators in these examples operate only on Integers, so the type of (+) is Integer->Integer -» Integer. data D a = A Integer | B Bool | C a data Pair a b = Pab data List aNil | Cons a (List a) al: al-(P (P 3 (True && (3 P x (P x y))) (C 4) (C True ) a5 = (\x-> (lx-> (P x (C x)))) 3 True (lx-> ('mod- ((lx-> (ly-> x y y)) a6 x)) (+) 4) =
0 0
Add a comment Improve this question Transcribed image text
Answer #1

a1: is true satisfying the condition

a2: is false div not satisfied

a3: is true it satisfying condition

a4:is true satisfies condition

a5:true satisfying condition

a6: satisfying + condition

Add a comment
Know the answer?
Add Answer to:
Haskell coding problem please do problem two Here is problem one for the types Problem Two (Polymorphic Type Inference...
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
  • Haskell coding problem please do the last 3 Problem One (Non-Polymorphic Type Inference): Give the type of the followin...

    Haskell coding problem please do the last 3 Problem One (Non-Polymorphic Type Inference): Give the type of the following expressions. We assume that we can have Integer and Bools as defined in the Haskell Prelude. Assume that all arithmetic operators in these examples operate only on Integers, so the type of (+) is Integer->Integer -» Integer. data D a = A Integer | B Bool | C a data Pair a b = Pab data List aNil | Cons a...

  • Can you please write the two C++ modules below is a step by step instuctions to...

    Can you please write the two C++ modules below is a step by step instuctions to follow that will make it very easy thanks. Create a module called pqueue.cpp that implements priority queues, with a header file calledpqueue.hthat describes what pqueue.cpp exports. The interface includes the following, and nothing else. Types ItemType and PriorityType are discussed below under the refinement plan. A type, PriorityQueue. Creating a PriorityQueue object with line PriorityQueue q; makes q be an initially empty priority queue....

  • Can you please write the two C++ modules below is a step by step instuctions to follow that will ...

    Can you please write the two C++ modules below is a step by step instuctions to follow that will make it very easy thanks. Create a module called pqueue.cpp that implements priority queues, with a header file calledpqueue.hthat describes what pqueue.cpp exports. The interface includes the following, and nothing else. Types ItemType and PriorityType are discussed below under the refinement plan. A type, PriorityQueue. Creating a PriorityQueue object with line PriorityQueue q; makes q be an initially empty priority queue....

  • use python IDEL Please highlight the answer Problem 1 Errors and Exceptions. There are two main...

    use python IDEL Please highlight the answer Problem 1 Errors and Exceptions. There are two main types of errors: syntax errors and runtime errors. Syntax errors are detected by the Python interpreter before the program execution during the parsing stage (parsing is a process, during which the Python interpreter analyzes the grammatical structure of the program). Runtime errors are errors in a program that are not detected by the Python interpreter during its parsing stage. They are further divided into...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

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