From 82b1bc1f874bf65acd4281fb0a4b833e9f0484a1 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Aug 2017 16:46:51 -0400 Subject: [PATCH] Define a helper to match context infix. --- src/Data/Syntax.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Data/Syntax.hs b/src/Data/Syntax.hs index fe3dbc515..0441ec5b7 100644 --- a/src/Data/Syntax.hs +++ b/src/Data/Syntax.hs @@ -9,6 +9,7 @@ import Data.Align.Generic import Data.ByteString (ByteString) import qualified Data.Error as Error import Data.Foldable (toList) +import Data.Function ((&)) import Data.Ix import Data.List.NonEmpty (NonEmpty(..), nonEmpty) import Data.Functor.Classes.Eq.Generic @@ -67,6 +68,14 @@ postContextualize context rule end = make <$> rule <*> Assignment.manyThrough co Just cs -> (makeTerm1 (Context cs node), end) _ -> (node, end) +infixContext :: (Context :< fs, Alternative m, Semigroup a, HasCallStack, Apply1 Foldable fs) + => m (Term (Union fs) a) + -> m (Term (Union fs) a) + -> m (Term (Union fs) a) + -> [m (Term (Union fs) a -> Term (Union fs) a -> Union fs a)] + -> m (Union fs a) +infixContext context left right operators = uncurry (&) <$> postContextualize context left (Assignment.choice operators) <*> right + -- Undifferentiated