{-# LANGUAGE Safe #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Algebra.PartialOrd.Instances () where
import Algebra.PartialOrd (PartialOrd (..))
import Data.Monoid (Endo (..))
import Data.Universe.Class (Finite (..))
import Data.Universe.Instances.Eq ()
instance (PartialOrd v, Finite k) => PartialOrd (k -> v) where
k -> v
f leq :: (k -> v) -> (k -> v) -> Bool
`leq` k -> v
g = (k -> Bool) -> [k] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (\k
k -> k -> v
f k
k v -> v -> Bool
forall a. PartialOrd a => a -> a -> Bool
`leq` k -> v
g k
k) [k]
forall a. Finite a => [a]
universeF
instance (PartialOrd v, Finite v) => PartialOrd (Endo v) where
Endo v -> v
f leq :: Endo v -> Endo v -> Bool
`leq` Endo v -> v
g = v -> v
f (v -> v) -> (v -> v) -> Bool
forall a. PartialOrd a => a -> a -> Bool
`leq` v -> v
g