EitherT.filter and filterWith are evil, stupid, and wrong.

311 views
Skip to first unread message

Kris Nuttycombe

unread,
May 16, 2013, 6:37:32 PM5/16/13
to sca...@googlegroups.com
The offenders:

 99   /** Filter on the right of this disjunction. */
100   def filter[AA >: A](p: B => Boolean)(implicit M: Monoid[AA], F: Functor[F]): EitherT[F, AA, B] =
101     EitherT(F.map(run)(_.filter[AA](p)))
102 
103   /** Alias for `filter`. */
104   def withFilter[AA >: A](p: B => Boolean)(implicit M: Monoid[AA], F: Functor[F]): EitherT[F, AA, B] =
105     filter[AA](p)(M, F)

Note the presence of "implicit M: Monoid." To provide a default value for the LHS. This is evil, stupid, and wrong - the zero for a monoid has no bearing on the correct value for one side of a disjunctive type.

I believe that these methods should be deprecated, then removed with great prejudice. These are hangovers from the bad old days of Zero. Implicit wrongness for the purpose of pleasing for-comprehension syntax has no place in scalaz.

Kris

Paul Chiusano

unread,
May 16, 2013, 8:25:04 PM5/16/13
to sca...@googlegroups.com
+1


--
You received this message because you are subscribed to the Google Groups "scalaz" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaz+un...@googlegroups.com.
To post to this group, send email to sca...@googlegroups.com.
Visit this group at http://groups.google.com/group/scalaz?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tony Morris

unread,
May 16, 2013, 8:30:31 PM5/16/13
to sca...@googlegroups.com
> --
> You received this message because you are subscribed to the Google
> Groups "scalaz" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to scalaz+un...@googlegroups.com.
> To post to this group, send email to sca...@googlegroups.com.
> Visit this group at http://groups.google.com/group/scalaz?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
I am a bit busy at the moment, so I will elaborate when I can.
Either#filter was written because it was determined to be useful, not
because of hangovers from Zero or to satisfy for-comprehensions. It was
arrived at by first determining suitable properties/laws of the filter
function, then ensuring that these are satisfied. I would have to figure
that out again to be sure.

Rather than appeal to possible history, I would suggest formulating and
agreeing on properties that filter should satisfy, then asking whether
this implementation satisfies those properties. The answer to this
question determines the future of these implementations.


--
Tony Morris
http://tmorris.net/

Kenji Yoshida

unread,
Dec 18, 2013, 9:57:13 PM12/18/13
to sca...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages