The simplest instance I could find was just
{-# LANGUAGE UndecidableInstances, FlexibleContexts #-}
import Data.Function (on)
instance Eq (f (Fix f)) => Eq (Fix f) where
(==) = (==) `on` unFix
All that we require is that Fix f
is an instance of Eq
precisely when f (Fix f)
is an instance of Eq
. Since in general we have instances like Eq a => Eq (f a)
this works just fine.
> Fx Zero == Fx Zero
True