Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.2. What are the types of the following functions? (Note that this is question 3. in section 3.11 of the book.) Hint: checking them with

image text in transcribed

1.2. What are the types of the following functions? (Note that this is question 3. in section 3.11 of the book.) Hint: checking them with GHCi is a good idea. a. second xs = head (tail xs) In particular, explain why second has the type that it has, i.e., tail :: [a] -> [a]", hence xs :: [a]", and head :: [a] -> a', etc. Why does chaining them together like in the definition of second give us the type that it has? This will use the fact that if f is a function that maps arguments of type a' to results of type 'b', and 'e' is an expression of type 'a', then the application 'fe' has type 'b: if f:: a -> b' and `e: a', then 'fe::b b. swap (x,y) = (y,x) Why can 'x' and y correspond to different types? 1.2. What are the types of the following functions? (Note that this is question 3. in section 3.11 of the book.) Hint: checking them with GHCi is a good idea. a. second xs = head (tail xs) In particular, explain why second has the type that it has, i.e., tail :: [a] -> [a]", hence xs :: [a]", and head :: [a] -> a', etc. Why does chaining them together like in the definition of second give us the type that it has? This will use the fact that if f is a function that maps arguments of type a' to results of type 'b', and 'e' is an expression of type 'a', then the application 'fe' has type 'b: if f:: a -> b' and `e: a', then 'fe::b b. swap (x,y) = (y,x) Why can 'x' and y correspond to different types

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago