Search Header Logo
Functor and Applicative Quiz

Functor and Applicative Quiz

Assessment

Presentation

Computers

University

Practice Problem

Hard

Created by

Jess Foster

Used 71+ times

FREE Resource

3 Slides • 9 Questions

1

Functors

and

Applicatives

2

​Functor

  • ​Generalisation of `map` for other types

  • ​Applying functions into a context

  • ​Structure preserving

  • ​Once you understand it, you will always know the behaviour of fmap for any Functor, without needing to know the implementation!

media
media
media

​Using InstanceSigs

extension

3

Fill in the Blank

Question image

What is the value of xs?

(Make sure to remove all spaces, no advanced matching option sadly)

4

Fill in the Blank

Question image

What is the value of xs?

(Make sure to remove all spaces)

5

Fill in the Blank

Question image

What is the value of x?

6

Fill in the Blank

Question image

What is the value of y?

7

Fill in the Blank

Question image

What is the value of t?

8

​Applicative

  • <*>

    • Applying functions within a context

    • ​Output structure depends on input structure alone. Values cannot affect structure

  • pure

    • Lifting values into a context

    • Preserves structure when used with <*>

  • ​All Applicatives are also Functors

media
media

​Using InstanceSigs

extension

9

Fill in the Blank

Question image

What is the value of x? (the second one)

10

Multiple Select

If the only information we have about a type is that it has an Applicative instance, what do we automatically know about it?

1

We know it also has a Functor instance

2

We know how <*> will produce new structure

3

We know what its structure looks like

4

We know a way to create a value of that type

5

We know we can sequence values of that type and combine their results

11

Multiple Select

Which of the following are true statements?

1

For a particular type, only one kind of Applicative behaviour is possible

2

For a particular type, only one kind of Functor behaviour is possible

3

For a particular type, it cannot have more than one Applicative behaviour simultaneously

4

Applicative is strictly more 'powerful' than Functor

5

All Functors are also Applicatives

12

Fill in the Blank

Question image

How many elements does xs have?

Functors

and

Applicatives

Show answer

Auto Play

Slide 1 / 12

SLIDE