Signature of flatMapF in OptionT, ListT

34 views
Skip to first unread message

Joheinz

unread,
Jun 20, 2015, 3:55:45 PM6/20/15
to sca...@googlegroups.com
The signature of flatMapF in OptionT is

def flatMapF[B](f: A => F[B])(implicit F: Monad[F]): OptionT[F, B]

whereas the signature of flatMapF in ListT is

def flatMapF[B](f: A => M[List[B]])(implicit M: Monad[M]) : ListT[M, B]

Me thinks, both can't be right. I would favour the version of OptionT, as OptionT and ListT have defined flatMap in the style of:

def flatMap[B](f: A => OptionT[F, B])(implicit F: Monad[F]): OptionT[F, B] (for ListT with ListT respectively).

Regards

Markus




Joheinz

unread,
Jun 21, 2015, 7:05:08 AM6/21/15
to sca...@googlegroups.com
BTW, this is what I came up with for flatMapF in ListT:

def flatMapF[B](f: A => M[B])(implicit M: Monad[M], T: Traverse[List]) : ListT[M, B] = new ListT[M,B] (
M.bind(run) { list =>
T.traverse(list)(f)
}
)

Is this correct, the right approach? Markus

Reply all
Reply to author
Forward
0 new messages