Question: 3 a ) Implement Functors ( 4 points ) Task: Complete the implementations of the functors in functional.Functor. Extend the given objects so that they
a Implement Functors points
Task: Complete the implementations of the functors in functional.Functor. Extend the given objects so that they inherit from Functor and implement the necessary methods.
The functors for the data structures Option, Tree and Graph need to be implemented. b Apply functors point
Task: Combine ListFunctor and OptionFunctor to implement capitalizeNames method. This receives a list of names for which some entries are not present hence the type OptionString The method is intended to transform the input so that after execution the first letter of all existing entries is capitalized.
Example: capitalizeNamesListSomemax None ListSomeMax None
Note: You can use the String.capitalize method to implement it
package functional
import functional.data.Graph Tree
trait FoldableF:
def foldAt: FAm: MonoidA: A
def foldMapA Bt: FAf: A Bm: MonoidB: B
object ListFoldable extends FoldableList:
override def foldAt: ListAm: MonoidA: A t match
case Nil mempty
case hd :: tl mcombinehd foldtlm
override def foldMapA Bt: ListAf: A Bm: MonoidB: B
object TreeFoldable TODO
object GraphFoldable TODO
def wordCountFt: FStringf: FoldableF: Int
def charCountFt: FStringf: FoldableF: Int
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
