From 9ff747c1cf0760f85ccb831f639cd7e97bac4d25 Mon Sep 17 00:00:00 2001 From: L0neGamer Date: Fri, 5 Jun 2026 19:05:29 +0100 Subject: [PATCH] removing extraneous methods and canonising Results --- Text/Earley/Generator/Internal.hs | 2 -- Text/Earley/Grammar.hs | 4 +--- Text/Earley/Parser/Internal.hs | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Text/Earley/Generator/Internal.hs b/Text/Earley/Generator/Internal.hs index cec9871..e256134 100644 --- a/Text/Earley/Generator/Internal.hs +++ b/Text/Earley/Generator/Internal.hs @@ -83,7 +83,6 @@ instance Alternative (Results t s) where Results sxs <|> Results sys = Results $ (<|>) <$> sxs <*> sys instance Monad (Results t s) where - return = pure Results stxs >>= f = Results $ do xs <- stxs concat <$> mapM (\(x, ts) -> fmap (\(y, ts') -> (y, ts' ++ ts)) <$> unResults (f x)) xs @@ -93,7 +92,6 @@ instance Semigroup (Results s t a) where instance Monoid (Results s t a) where mempty = empty - mappend = (<>) ------------------------------------------------------------------------------- -- * States and continuations diff --git a/Text/Earley/Grammar.hs b/Text/Earley/Grammar.hs index 7240040..4b4ae6d 100644 --- a/Text/Earley/Grammar.hs +++ b/Text/Earley/Grammar.hs @@ -78,7 +78,6 @@ instance Semigroup a => Semigroup (Prod r e t a) where -- | Lifted instance: @mempty = 'pure' 'mempty'@ instance Monoid a => Monoid (Prod r e t a) where mempty = pure mempty - mappend = (<>) instance Functor (Prod r e t) where {-# INLINE fmap #-} @@ -161,11 +160,10 @@ instance Functor (Grammar r) where fmap f (Return x) = Return $ f x instance Applicative (Grammar r) where - pure = return + pure = Return (<*>) = ap instance Monad (Grammar r) where - return = Return RuleBind ps f >>= k = RuleBind ps (f >=> k) FixBind f g >>= k = FixBind f (g >=> k) Return x >>= k = k x diff --git a/Text/Earley/Parser/Internal.hs b/Text/Earley/Parser/Internal.hs index a2b089d..cc76eae 100644 --- a/Text/Earley/Parser/Internal.hs +++ b/Text/Earley/Parser/Internal.hs @@ -85,7 +85,6 @@ instance Alternative (Results s) where Results sxs <|> Results sys = Results $ (<|>) <$> sxs <*> sys instance Monad (Results s) where - return = pure Results stxs >>= f = Results $ do xs <- stxs concat <$> mapM (unResults . f) xs @@ -95,7 +94,6 @@ instance Semigroup (Results s a) where instance Monoid (Results s a) where mempty = empty - mappend = (<>) ------------------------------------------------------------------------------- -- * States and continuations