Why isn't there an instance Eq (a -> b) ?

  allValues :: (Bounded a,Enum a) => [a]
  allValues = enumFrom minBound

  instance (Bounded a,Enum a,Eq b) => Eq (a -> b) where
    p == q = fmap p allValues == fmap q allValues

Of course, it's not perfect, since empty types are finite but not Bounded. One can nevertheless make them instances of Bounded with undefined bounds, and have enumFrom and friends always return the empty list.

It seems one should also be able to write

  instance (Bounded a,Enum a) => Traversable (a -> b) where ???

But this turns out to be curiously hard.

--
Ashley Yakeley

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to