diff --git a/src/MA/Functors/Distribution.hs b/src/MA/Functors/Distribution.hs index 55f6244bd68b57bbbf6ef6b0544b5e4337435c33..b186a31fa07a94e8fa52c751b8df3799680d155c 100644 --- a/src/MA/Functors/Distribution.hs +++ b/src/MA/Functors/Distribution.hs @@ -46,7 +46,7 @@ deriving instance Show (Distribution ()) instance ParseMorphism Distribution where parseMorphismPoint (Distribution inner) = do - (h1, succs) <- parseMorphismPoint (RealValued inner) + (h1, succs) <- parseMorphismPoint (MonoidValued @ADouble inner) when (h1 /= 1) $ fail "distribution: Sum of outgoing labels is not 1" diff --git a/src/MA/Functors/MonoidValued.hs b/src/MA/Functors/MonoidValued.hs index 64ca17ffff9c81c6dad4921ba66a4dd40dd6885e..4d345b1927c1fea76580ee63a2dbceb87f7ca51c 100644 --- a/src/MA/Functors/MonoidValued.hs +++ b/src/MA/Functors/MonoidValued.hs @@ -31,9 +31,7 @@ import qualified MA.Parser.Lexer as L import MA.Parser.Types import MA.FunctorDescription -data MonoidValued m a where - RealValued :: a -> MonoidValued ADouble a - IntValued :: a -> MonoidValued Int a +data MonoidValued m a = MonoidValued a deriving instance Show (MonoidValued m ()) deriving instance Functor (MonoidValued m) @@ -45,7 +43,7 @@ intValued = FunctorDescription { name = "Integer-valued" , syntaxExample = "Z^X | ℤ^X" , functorExprParser = - prefix ((L.symbol "Z" <|> L.symbol "ℤ") >> L.symbol "^" >> pure IntValued) + prefix ((L.symbol "Z" <|> L.symbol "ℤ") >> L.symbol "^" >> pure MonoidValued) } realValued :: FunctorDescription (MonoidValued ADouble) @@ -53,7 +51,7 @@ realValued = FunctorDescription { name = "Real-valued" , syntaxExample = "R^X | ℝ^X" , functorExprParser = prefix - ((L.symbol "R" <|> L.symbol "ℝ") >> L.symbol "^" >> pure RealValued) + ((L.symbol "R" <|> L.symbol "ℝ") >> L.symbol "^" >> pure MonoidValued) } data MonoidWeight m = MonoidWeight !m !m @@ -88,10 +86,10 @@ parseMorphismPointHelper inner weightParser = do {-# SPECIALIZE parseMorphismPointHelper :: MorphParser l h1 Int -> MorphParser l h1 ADouble -> MorphParser l h1 (ADouble, Vector (Int, ADouble)) #-} instance ParseMorphism (MonoidValued Int) where - parseMorphismPoint (IntValued inner) = parseMorphismPointHelper inner L.decimal + parseMorphismPoint (MonoidValued inner) = parseMorphismPointHelper inner L.decimal instance ParseMorphism (MonoidValued ADouble) where - parseMorphismPoint (RealValued inner) = parseMorphismPointHelper inner L.adouble + parseMorphismPoint (MonoidValued inner) = parseMorphismPointHelper inner L.adouble instance (Num m, Ord m) => RefinementInterface (MonoidValued m) where init :: H1 (MonoidValued m) -> [Label (MonoidValued m)] -> Weight (MonoidValued m)