catch instance Foldable ((, ) a)

Henning Thielemann lemming at henning-thielemann.de
Fri May 29 14:43:15 UTC 2020


On Fri, 29 May 2020, Zemyla wrote:

> I am opposed to all the hate on Foldable ((,) a).

It's not about hate, but in _my_ code using an instance like Foldable ((,) 
a) or Functor ((,) a) or Traversable ((,) a) is a bug, because I would not 
use it by intention. That's why I want at least a warning, where there was 
a type error before GHC-7.10.

In my code I would define a custom data type

    data Decorated a b = Decorated a b

instead of generic pair or I would use Writer monad, if that's 
appropriate.

> It's a failure of expectations more than anything else, and I really 
> don't think anyone beyond beginner level is routinely running into bugs 
> because they tried to use length or toList on a tuple.

You can also call it a beginner's problem to use tuples everywhere, where 
custom data types would be the better choice.


More information about the Libraries mailing list