{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
module Data.Universe.Instances.Extended (
Universe(..), Finite(..)
) where
import Control.Comonad.Trans.Traced (TracedT (..))
import Data.Functor.Rep (Representable (..), Co(..))
import Data.Universe.Class (Universe (..), Finite (..))
import Data.Universe.Helpers (retag, Tagged, Natural)
instance (Representable f, Finite (Rep f), Ord (Rep f), Universe a)
=> Universe (Co f a)
where universe = map tabulate universe
instance (Representable f, Finite s, Ord s, Finite (Rep f), Ord (Rep f), Universe a)
=> Universe (TracedT s f a)
where universe = map tabulate universe
instance (Representable f, Finite (Rep f), Ord (Rep f), Finite a)
=> Finite (Co f a)
where universeF = map tabulate universeF; cardinality = retag (cardinality :: Tagged (Rep (Co f) -> a) Natural)
instance (Representable f, Finite s, Ord s, Finite (Rep f), Ord (Rep f), Finite a)
=> Finite (TracedT s f a)
where universeF = map tabulate universeF; cardinality = retag (cardinality :: Tagged (Rep (TracedT s f)) Natural)