1
1
mirror of https://github.com/github/semantic.git synced 2024-12-30 10:27:45 +03:00

Define a smart constructor for parse.

This commit is contained in:
Rob Rix 2019-09-30 14:28:40 -04:00
parent bba02fe178
commit 856189ed15
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -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)