1
1
mirror of https://github.com/github/semantic.git synced 2024-11-23 16:37:50 +03:00

Define a let' macro.

This commit is contained in:
Rob Rix 2022-02-01 14:12:06 -05:00
parent 1f2b8a1490
commit ff516c39ac
No known key found for this signature in database
GPG Key ID: 2BE643E01DC032AE

View File

@ -21,6 +21,8 @@ module Analysis.Syntax
, eval0
, eval
, Interpret(..)
-- * Macro-expressible syntax
, let'
-- * Parsing
, parseFile
, parseGraph
@ -28,8 +30,9 @@ module Analysis.Syntax
) where
import Analysis.Effect.Domain
import Analysis.Effect.Env (Env)
import Analysis.Effect.Env (Env, bind)
import Analysis.Effect.Store
import Analysis.Name (Name)
import Control.Applicative (Alternative(..), liftA3)
import Control.Effect.Labelled
import Control.Monad (guard)
@ -115,6 +118,15 @@ instance (Has (Env addr) sig m, HasLabelled Store (Store addr val) sig m, Has (D
throw e = Interpret (\ eval -> eval e >>= ddie)
-- Macro-expressible syntax
let' :: (Has (Env addr) sig m, HasLabelled Store (Store addr val) sig m) => Name -> val -> m a -> m a
let' n v m = do
addr <- alloc n
addr .= v
bind n addr m
-- Parsing
parseFile :: Syntax rep => FilePath -> IO (Either (A.JSONPath, String) (IntMap.IntMap rep))