Why does Foldable inherit from Functor in Frege?

86 Views Asked by At

In Haskell, the class Foldable is standalone i.e.

class Foldable t where ...

However, in Frege:

class Functor t => Foldable t where ...

Why was this constraint introduced? What ill-formed programs/ideas can it rule out?

It prevented me from defining an instance Foldable HashSet, where HashSet is a custom data type which wraps Data.HashMap to provide a set-based interface. (It can be worked around by applying toList first, so it's not a serious issue.)

2

There are 2 best solutions below

1
On BEST ANSWER

I can only guess that it used to be the case that Haskell's Foldable did have Functor as a superclass once and that Frege inherited the Foldable code at this time. Could've been 2012 or so.

I'm not sure I understand your concern as Data.HashMap is indeed a Functor. But anyway, I invite you to design a patch and make a pull request.

1
On

I think this discussion give you the whole feedback on the topic (especially part about Sets) Haskell : An example of a Foldable which is not a Functor (or not Traversable)?