Commit 68fc692e authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

Remove unnecessary constraints from RefinementInterface

The RefinementInterface class itself doesn't require that the type is
Functor, Foldable or Traversable. This constraint is now required at
the use sites where it's needed.
parent 47a68168
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
module MA.Functors.SomeFunctor
( SomeFunctor
......@@ -14,9 +16,11 @@ import MA.Coalgebra.RefinementTypes
import MA.FunctorExpression.Parser
import MA.Coalgebra.Parser
type Suitable f = (RefinementInterface f, Functor f, Foldable f, Traversable f)
data SomeFunctor a where
SomeFunctor
:: (Traversable f, RefinementInterface f, Typeable f, ParseMorphism f)
:: (Suitable f, Typeable f, ParseMorphism f)
=> f a
-> SomeFunctor a
......@@ -25,23 +29,19 @@ deriving instance Foldable SomeFunctor
deriving instance Traversable SomeFunctor
someFunctor ::
(Traversable f, RefinementInterface f, Typeable f, ParseMorphism f)
(Suitable f, Typeable f, ParseMorphism f)
=> FunctorParser f
-> FunctorParser SomeFunctor
someFunctor = transParser SomeFunctor
-- XXX: Hack to support old refinement interface
instance Show (SomeFunctor ()) where
show _ = "SomeFunctor ()"
data SomeLabel where
SomeLabel :: RefinementInterface f => TypeRep f -> Label f -> SomeLabel
SomeLabel :: Suitable f => TypeRep f -> Label f -> SomeLabel
data SomeWeight where
SomeWeight :: RefinementInterface f => TypeRep f -> Weight f -> SomeWeight
SomeWeight :: Suitable f => TypeRep f -> Weight f -> SomeWeight
data SomeH1 where
SomeH1 :: RefinementInterface f => TypeRep f -> H1 f -> SomeH1
SomeH1 :: Suitable f => TypeRep f -> H1 f -> SomeH1
instance Eq SomeH1 where
(SomeH1 f1 a) == (SomeH1 f2 b) = case eqTypeRep f1 f2 of
......@@ -54,7 +54,7 @@ instance Ord SomeH1 where
Just HRefl -> compare a b
data SomeH3 where
SomeH3 :: RefinementInterface f => TypeRep f -> H3 f -> SomeH3
SomeH3 :: Suitable f => TypeRep f -> H3 f -> SomeH3
instance Eq SomeH3 where
(SomeH3 f1 a) == (SomeH3 f2 b) = case eqTypeRep f1 f2 of
......@@ -95,8 +95,8 @@ instance RefinementInterface SomeFunctor where
instance ParseMorphism SomeFunctor where
parseMorphismPoint (SomeFunctor (f :: tf (m x))) = do
convert (parseMorphismPoint f)
fmap convert (parseMorphismPoint f)
where
fRep = typeRep @tf
convert = fmap (\(h1, succs) -> (SomeH1 fRep h1, map (\(x,y) -> (x, SomeLabel fRep y)) succs))
convert = (\(h1, succs) -> (SomeH1 fRep h1, map (\(x,y) -> (x, SomeLabel fRep y)) succs))
......@@ -5,8 +5,7 @@ module MA.RefinementInterface where
import MA.Coalgebra.RefinementTypes
class (Ord (H1 h), Ord (H3 h), Functor h, Foldable h, Traversable h) =>
RefinementInterface (h :: * -> *)
class (Ord (H1 h), Ord (H3 h)) => RefinementInterface (h :: * -> *)
where
init :: H1 h -> [Label h] -> Weight h
update :: [Label h] -> Weight h -> (Weight h, H3 h, Weight h)
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