Search code examples
typesfrege

Why does Foldable inherit from Functor in Frege?


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.)


Solution

  • 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.