Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started