From 856189ed15e2611c62e177387e15f571e933a12b Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 30 Sep 2019 14:28:40 -0400 Subject: [PATCH] Define a smart constructor for parse. --- src/Semantic/Parse.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Semantic/Parse.hs b/src/Semantic/Parse.hs index d78e58450..cf819e559 100644 --- a/src/Semantic/Parse.hs +++ b/src/Semantic/Parse.hs @@ -1,6 +1,7 @@ {-# LANGUAGE ExistentialQuantification #-} module Semantic.Parse ( Parse(..) +, parse ) where import Control.Effect.Carrier @@ -17,3 +18,11 @@ instance HFunctor Parse where instance Effect Parse where handle state handler (Parse parser blob k) = Parse parser blob (handler . (<$ state) . k) + + +-- | Parse a 'Blob' with the given 'Parser'. +parse :: (Member Parse sig, Carrier sig m) + => Parser term + -> Blob + -> m term +parse parser blob = send (Parse parser blob pure)