{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >=704
{-# LANGUAGE Safe #-}
#elif __GLASGOW_HASKELL__ >=702
{-# LANGUAGE Trustworthy #-}
#endif
module Data.Universe.Instances.Eq (
  -- | An 'Eq' instance for functions, given the input is 'Finite' and the
  -- output is 'Eq'. Compares pointwise.
  Eq(..)
  ) where

import Data.Monoid
import Data.Universe.Class

instance (Finite a, Eq b) => Eq (a -> b) where
  a -> b
f == :: (a -> b) -> (a -> b) -> Bool
== a -> b
g = [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and [a -> b
f a
x b -> b -> Bool
forall a. Eq a => a -> a -> Bool
== a -> b
g a
x | a
x <- [a]
forall a. Finite a => [a]
universeF]

instance (Finite a, Eq a) => Eq (Endo a) where
  Endo a -> a
f == :: Endo a -> Endo a -> Bool
== Endo a -> a
g = a -> a
f (a -> a) -> (a -> a) -> Bool
forall a. Eq a => a -> a -> Bool
== a -> a
g