lab07: impl functor
This commit is contained in:
@@ -42,7 +42,8 @@ be applied to every element of the tree. As a review of the last lab, define
|
|||||||
fmap for FacetedValues.
|
fmap for FacetedValues.
|
||||||
|
|
||||||
> instance Functor FacetedValue where
|
> instance Functor FacetedValue where
|
||||||
> fmap f v = error "Your code here"
|
> fmap f (Raw x) = Raw (f x)
|
||||||
|
> fmap f (Facet label auth unauth) = Facet label (fmap f auth) (fmap f unauth)
|
||||||
|
|
||||||
|
|
||||||
The following function gives an example of how a FacetedValue can be used.
|
The following function gives an example of how a FacetedValue can be used.
|
||||||
@@ -67,7 +68,7 @@ In order to make that work, we need need to add support for Applicative Functors
|
|||||||
Define the behavior of the Functor below
|
Define the behavior of the Functor below
|
||||||
|
|
||||||
> instance Applicative FacetedValue where
|
> instance Applicative FacetedValue where
|
||||||
> pure = error "Your code here"
|
> pure = Raw
|
||||||
> fv1 <*> fv2 = error "Your code here"
|
> fv1 <*> fv2 = error "Your code here"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user