Commit beb6a13d authored by Bastian Kauschke's avatar Bastian Kauschke
Browse files

implement Eq1 for all functors

parent ab6f7674
......@@ -31,6 +31,7 @@ import Control.Monad.ST
import Unsafe.Coerce
import Data.Foldable
import Data.Eq.Deriving ( deriveEq1 )
import Text.Show.Deriving ( deriveShow1 )
import Data.Vector ( Vector )
import qualified Data.Vector as V
......@@ -58,6 +59,7 @@ data Inner f a = Direct a | Absorbed (f a)
deriving (Functor, Foldable, Traversable)
$(deriveShow1 ''Inner)
$(deriveEq1 ''Inner)
newtype AbsorbingPolynomial f a = AbsorbingPolynomial (Polynomial (Inner f a))
......@@ -70,7 +72,7 @@ instance (Printable f) => Printable (AbsorbingPolynomial f) where
) <$> poly)
$(deriveShow1 ''AbsorbingPolynomial)
$(deriveEq1 ''AbsorbingPolynomial)
absorbInnerFunctors
:: Polynomial (FunctorExpression f a)
......
......@@ -18,6 +18,7 @@ import Data.Bits
import Text.Megaparsec
import qualified Data.Vector as V
import qualified Data.Vector.Utils as V
import Data.Eq.Deriving (deriveEq1)
import Text.Show.Deriving (deriveShow1)
import qualified Data.Text.Prettyprint as Doc
import Data.Text.Prettyprint ((<+>))
......@@ -33,6 +34,7 @@ newtype Powerset a = Powerset a
deriving (Show,Functor,Foldable,Traversable)
$(deriveShow1 ''Powerset)
$(deriveEq1 ''Powerset)
instance Printable Powerset where
printMe cfg (Powerset x) = withName cfg "Powerset" <> "P" <> x
......
......@@ -40,6 +40,7 @@ import Copar.RefinementInterface
type Suitable f
= ( RefinementInterface f
, Printable f
, Eq1 f
, Functor f
, Foldable f
, Traversable f
......@@ -64,10 +65,15 @@ instance Show1 SomeFunctor where
liftShowsPrec shows' showsList' pred (SomeFunctor f) =
liftShowsPrec shows' showsList' pred f
instance Eq1 SomeFunctor where
liftEq eq' (SomeFunctor (lhs :: f' a)) (SomeFunctor (rhs :: f'' b)) =
case eqTypeRep (typeRep @f') (typeRep @f'') of
Nothing -> False
Just HRefl -> liftEq eq' lhs rhs
instance Printable SomeFunctor where
printMe cfg (SomeFunctor x) = printMe cfg x
-- | Apply a natural transformation under the 'SomeFunctor'.
--
-- This can change the functor stored in the 'SomeFunctor'. Transformations with
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment