prlg/app/Env.hs
Mirek Kratochvil 0092723895 microlens and an ugly parse of ,(something,something)
btw we triggered a ghc bug here with iscallTok in parser. Apparently it kills
`call` for whichever reason. New ghc solved it.
2023-02-26 21:43:25 +01:00

26 lines
587 B
Haskell

module Env where
import Code (InterpFn, PrlgEnv)
import CodeLens
import qualified IR
import Lens.Micro.Mtl
withStrTable :: (IR.StrTable -> (IR.StrTable, a)) -> Env.PrlgEnv a
withStrTable f = do
(st', x) <- f <$> use strtable
strtable .= st'
return x
findStruct :: String -> Int -> Env.PrlgEnv IR.Id
findStruct str arity = do
stri <- findAtom str
return IR.Id {IR.str = stri, IR.arity = arity}
findAtom :: String -> Env.PrlgEnv Int
findAtom = withStrTable . flip IR.strtablize
type PrlgEnv a = Code.PrlgEnv a
prlgError :: String -> InterpFn
prlgError = pure . pure . Left