mirror of
https://github.com/github/semantic.git
synced 2025-01-02 12:23:08 +03:00
Define a smart constructor for parse.
This commit is contained in:
parent
bba02fe178
commit
856189ed15
@ -1,6 +1,7 @@
|
|||||||
{-# LANGUAGE ExistentialQuantification #-}
|
{-# LANGUAGE ExistentialQuantification #-}
|
||||||
module Semantic.Parse
|
module Semantic.Parse
|
||||||
( Parse(..)
|
( Parse(..)
|
||||||
|
, parse
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Effect.Carrier
|
import Control.Effect.Carrier
|
||||||
@ -17,3 +18,11 @@ instance HFunctor Parse where
|
|||||||
|
|
||||||
instance Effect Parse where
|
instance Effect Parse where
|
||||||
handle state handler (Parse parser blob k) = Parse parser blob (handler . (<$ state) . k)
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user