2022-11-07 16:47:56 +03:00
|
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
|
|
|
|
module Commands.Repl where
|
|
|
|
|
2023-04-27 18:33:08 +03:00
|
|
|
import Commands.Base hiding
|
|
|
|
( command,
|
|
|
|
)
|
2023-05-30 11:19:09 +03:00
|
|
|
import Commands.Repl.Base
|
2022-11-07 16:47:56 +03:00
|
|
|
import Commands.Repl.Options
|
|
|
|
import Control.Exception (throwIO)
|
2023-05-30 11:19:09 +03:00
|
|
|
import Control.Monad.Except qualified as Except
|
|
|
|
import Control.Monad.Reader qualified as Reader
|
2022-11-07 16:47:56 +03:00
|
|
|
import Control.Monad.State.Strict qualified as State
|
2023-05-30 11:19:09 +03:00
|
|
|
import Control.Monad.Trans.Class (lift)
|
2022-11-07 16:47:56 +03:00
|
|
|
import Data.String.Interpolate (i, __i)
|
|
|
|
import Evaluator
|
2023-05-30 11:19:09 +03:00
|
|
|
import Juvix.Compiler.Concrete.Data.InfoTable qualified as Scoped
|
2023-03-30 14:39:27 +03:00
|
|
|
import Juvix.Compiler.Concrete.Data.Scope (scopePath)
|
|
|
|
import Juvix.Compiler.Concrete.Data.ScopedName (absTopModulePath)
|
2023-05-30 11:19:09 +03:00
|
|
|
import Juvix.Compiler.Concrete.Data.ScopedName qualified as Scoped
|
|
|
|
import Juvix.Compiler.Concrete.Language qualified as Concrete
|
|
|
|
import Juvix.Compiler.Concrete.Pretty qualified as Concrete
|
2023-05-03 21:04:31 +03:00
|
|
|
import Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.PathResolver (runPathResolver)
|
2023-09-01 14:37:06 +03:00
|
|
|
import Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.PathResolver.Error
|
2023-03-30 14:39:27 +03:00
|
|
|
import Juvix.Compiler.Core qualified as Core
|
2023-04-12 13:52:40 +03:00
|
|
|
import Juvix.Compiler.Core.Extra.Value
|
2022-11-07 16:47:56 +03:00
|
|
|
import Juvix.Compiler.Core.Info qualified as Info
|
|
|
|
import Juvix.Compiler.Core.Info.NoDisplayInfo qualified as Info
|
|
|
|
import Juvix.Compiler.Core.Pretty qualified as Core
|
2023-02-01 16:00:06 +03:00
|
|
|
import Juvix.Compiler.Core.Transformation qualified as Core
|
2023-03-31 01:57:44 +03:00
|
|
|
import Juvix.Compiler.Core.Transformation.DisambiguateNames (disambiguateNames)
|
2022-11-07 16:47:56 +03:00
|
|
|
import Juvix.Compiler.Internal.Language qualified as Internal
|
|
|
|
import Juvix.Compiler.Internal.Pretty qualified as Internal
|
2023-10-27 14:35:20 +03:00
|
|
|
import Juvix.Compiler.Pipeline.Package.Loader.Error
|
|
|
|
import Juvix.Compiler.Pipeline.Package.Loader.EvalEff.IO
|
2023-05-08 13:23:15 +03:00
|
|
|
import Juvix.Compiler.Pipeline.Repl
|
2023-10-23 14:38:52 +03:00
|
|
|
import Juvix.Compiler.Pipeline.Run
|
2023-05-03 21:04:31 +03:00
|
|
|
import Juvix.Compiler.Pipeline.Setup (entrySetup)
|
2023-11-03 14:51:45 +03:00
|
|
|
import Juvix.Data.CodeAnn (Ann)
|
2023-09-01 14:37:06 +03:00
|
|
|
import Juvix.Data.Effect.Git
|
|
|
|
import Juvix.Data.Effect.Process
|
2023-11-16 18:19:52 +03:00
|
|
|
import Juvix.Data.Effect.TaggedLock
|
2022-11-07 16:47:56 +03:00
|
|
|
import Juvix.Data.Error.GenericError qualified as Error
|
2023-05-30 11:19:09 +03:00
|
|
|
import Juvix.Data.NameKind
|
2023-10-30 16:05:52 +03:00
|
|
|
import Juvix.Extra.Paths qualified as P
|
2023-04-13 12:27:39 +03:00
|
|
|
import Juvix.Extra.Stdlib
|
2022-11-07 16:47:56 +03:00
|
|
|
import Juvix.Extra.Version
|
2023-05-30 11:19:09 +03:00
|
|
|
import Juvix.Prelude.Pretty
|
2022-11-07 16:47:56 +03:00
|
|
|
import Juvix.Prelude.Pretty qualified as P
|
|
|
|
import System.Console.ANSI qualified as Ansi
|
|
|
|
import System.Console.Haskeline
|
|
|
|
import System.Console.Repline
|
|
|
|
import System.Console.Repline qualified as Repline
|
|
|
|
|
2023-08-01 11:46:22 +03:00
|
|
|
printHelpTxt :: ReplOptions -> Repl ()
|
|
|
|
printHelpTxt opts = do
|
|
|
|
liftIO $ do
|
|
|
|
putStrLn normalCmds
|
|
|
|
let isDev = opts ^. replIsDev
|
|
|
|
when isDev (putStrLn devCmds)
|
|
|
|
where
|
|
|
|
normalCmds :: Text
|
|
|
|
normalCmds =
|
|
|
|
[__i|
|
2022-11-07 20:43:30 +03:00
|
|
|
EXPRESSION Evaluate an expression in the context of the currently loaded module
|
|
|
|
:help Print help text and describe options
|
|
|
|
:load FILE Load a file into the REPL
|
|
|
|
:reload Reload the currently loaded file
|
|
|
|
:type EXPRESSION Infer the type of an expression
|
2023-05-30 11:19:09 +03:00
|
|
|
:def IDENTIFIER Print the definition of the identifier
|
2023-05-30 19:19:39 +03:00
|
|
|
:doc IDENTIFIER Print the documentation of the identifier
|
2022-11-07 20:43:30 +03:00
|
|
|
:core EXPRESSION Translate the expression to JuvixCore
|
|
|
|
:multiline Start a multi-line input. Submit with <Ctrl-D>
|
|
|
|
:root Print the current project root
|
|
|
|
:version Display the Juvix version
|
|
|
|
:quit Exit the REPL
|
2022-11-07 16:47:56 +03:00
|
|
|
|]
|
2023-08-01 11:46:22 +03:00
|
|
|
|
|
|
|
devCmds :: Text
|
|
|
|
devCmds =
|
|
|
|
[__i|
|
|
|
|
:dev DEV CMD Command reserved for debugging
|
|
|
|
|]
|
2022-11-07 16:47:56 +03:00
|
|
|
|
2023-05-30 11:19:09 +03:00
|
|
|
replDefaultLoc :: Interval
|
2023-10-30 16:05:52 +03:00
|
|
|
replDefaultLoc = singletonInterval (mkInitialLoc P.replPath)
|
2023-05-30 11:19:09 +03:00
|
|
|
|
|
|
|
replFromJust :: Repl a -> Maybe a -> Repl a
|
|
|
|
replFromJust err = maybe err return
|
|
|
|
|
|
|
|
replFromEither :: Either JuvixError a -> Repl a
|
|
|
|
replFromEither = either (lift . Except.throwError) return
|
|
|
|
|
|
|
|
replGetContext :: Repl ReplContext
|
|
|
|
replGetContext = State.gets (^. replStateContext) >>= replFromJust noFileLoadedErr
|
|
|
|
|
|
|
|
replError :: AnsiText -> Repl a
|
|
|
|
replError msg =
|
|
|
|
lift
|
|
|
|
. Except.throwError
|
|
|
|
. JuvixError
|
|
|
|
$ GenericError
|
|
|
|
{ _genericErrorLoc = replDefaultLoc,
|
|
|
|
_genericErrorMessage = msg,
|
|
|
|
_genericErrorIntervals = [replDefaultLoc]
|
|
|
|
}
|
2022-11-07 16:47:56 +03:00
|
|
|
|
2023-05-30 11:19:09 +03:00
|
|
|
noFileLoadedErr :: Repl a
|
2023-05-31 10:53:08 +03:00
|
|
|
noFileLoadedErr = replError (mkAnsiText @Text "No file loaded. Load a file using the `:load FILE` command.")
|
2023-05-30 11:19:09 +03:00
|
|
|
|
2023-08-25 19:37:23 +03:00
|
|
|
welcomeMsg :: (MonadIO m) => m ()
|
2022-11-07 16:47:56 +03:00
|
|
|
welcomeMsg = liftIO (putStrLn [i|Juvix REPL version #{versionTag}: https://juvix.org. Run :help for help|])
|
|
|
|
|
2023-05-30 11:19:09 +03:00
|
|
|
multilineCmd :: String
|
|
|
|
multilineCmd = "multiline"
|
|
|
|
|
|
|
|
quit :: String -> Repl ()
|
|
|
|
quit _ = liftIO (throwIO Interrupt)
|
|
|
|
|
|
|
|
loadEntryPoint :: EntryPoint -> Repl ()
|
|
|
|
loadEntryPoint ep = do
|
|
|
|
artif <- liftIO (corePipelineIO' ep)
|
|
|
|
let newCtx =
|
|
|
|
ReplContext
|
|
|
|
{ _replContextArtifacts = artif,
|
|
|
|
_replContextEntryPoint = ep
|
|
|
|
}
|
|
|
|
State.modify (set replStateContext (Just newCtx))
|
|
|
|
let epPath :: Maybe (Path Abs File) = ep ^? entryPointModulePaths . _head
|
|
|
|
whenJust epPath $ \path -> liftIO (putStrLn [i|OK loaded: #{toFilePath path}|])
|
|
|
|
|
|
|
|
reloadFile :: String -> Repl ()
|
|
|
|
reloadFile _ = replGetContext >>= loadEntryPoint . (^. replContextEntryPoint)
|
|
|
|
|
|
|
|
pSomeFile :: String -> Prepath File
|
|
|
|
pSomeFile = mkPrepath
|
|
|
|
|
|
|
|
loadFile :: Prepath File -> Repl ()
|
|
|
|
loadFile f = do
|
2023-06-05 18:52:52 +03:00
|
|
|
entryPoint <- getReplEntryPointFromPrepath f
|
2023-05-30 11:19:09 +03:00
|
|
|
loadEntryPoint entryPoint
|
|
|
|
|
|
|
|
loadDefaultPrelude :: Repl ()
|
|
|
|
loadDefaultPrelude = whenJustM defaultPreludeEntryPoint $ \e -> do
|
2023-10-30 16:05:52 +03:00
|
|
|
root <- Reader.asks (^. replRoot . rootRootDir)
|
2023-09-07 19:26:19 +03:00
|
|
|
let hasInternet = not (e ^. entryPointOffline)
|
2023-05-30 11:19:09 +03:00
|
|
|
-- The following is needed to ensure that the default location of the
|
|
|
|
-- standard library exists
|
|
|
|
void
|
|
|
|
. liftIO
|
|
|
|
. runM
|
2023-09-07 19:26:19 +03:00
|
|
|
. evalInternet hasInternet
|
2023-05-30 11:19:09 +03:00
|
|
|
. runFilesIO
|
2023-10-23 21:01:36 +03:00
|
|
|
. runError @JuvixError
|
2023-05-30 11:19:09 +03:00
|
|
|
. runReader e
|
2023-11-16 18:19:52 +03:00
|
|
|
. runTaggedLockPermissive
|
2023-09-01 14:37:06 +03:00
|
|
|
. runLogIO
|
|
|
|
. runProcessIO
|
|
|
|
. runError @GitProcessError
|
2023-09-07 19:26:19 +03:00
|
|
|
. runGitProcess
|
2023-09-01 14:37:06 +03:00
|
|
|
. runError @DependencyError
|
2023-10-27 14:35:20 +03:00
|
|
|
. runError @PackageLoaderError
|
|
|
|
. runEvalFileEffIO
|
2023-05-30 11:19:09 +03:00
|
|
|
. runPathResolver root
|
2023-10-03 19:09:13 +03:00
|
|
|
$ entrySetup defaultDependenciesConfig
|
2023-05-30 11:19:09 +03:00
|
|
|
loadEntryPoint e
|
|
|
|
|
2023-10-30 16:05:52 +03:00
|
|
|
getReplEntryPoint :: (Root -> a -> GlobalOptions -> IO EntryPoint) -> a -> Repl EntryPoint
|
2023-06-05 18:52:52 +03:00
|
|
|
getReplEntryPoint f inputFile = do
|
2023-10-30 16:05:52 +03:00
|
|
|
root <- Reader.asks (^. replRoot)
|
2023-05-30 11:19:09 +03:00
|
|
|
gopts <- State.gets (^. replStateGlobalOptions)
|
2023-10-30 16:05:52 +03:00
|
|
|
liftIO (set entryPointSymbolPruningMode KeepAll <$> f root inputFile gopts)
|
2023-06-05 18:52:52 +03:00
|
|
|
|
|
|
|
getReplEntryPointFromPrepath :: Prepath File -> Repl EntryPoint
|
|
|
|
getReplEntryPointFromPrepath = getReplEntryPoint entryPointFromGlobalOptionsPre
|
|
|
|
|
|
|
|
getReplEntryPointFromPath :: Path Abs File -> Repl EntryPoint
|
|
|
|
getReplEntryPointFromPath = getReplEntryPoint entryPointFromGlobalOptions
|
2023-05-30 11:19:09 +03:00
|
|
|
|
|
|
|
displayVersion :: String -> Repl ()
|
|
|
|
displayVersion _ = liftIO (putStrLn versionTag)
|
|
|
|
|
|
|
|
replCommand :: ReplOptions -> String -> Repl ()
|
|
|
|
replCommand opts input = catchAll $ do
|
|
|
|
ctx <- replGetContext
|
|
|
|
let tab = ctx ^. replContextArtifacts . artifactCoreTable
|
|
|
|
evalRes <- compileThenEval ctx input
|
|
|
|
whenJust evalRes $ \n ->
|
|
|
|
if
|
|
|
|
| Info.member Info.kNoDisplayInfo (Core.getInfo n) -> return ()
|
|
|
|
| opts ^. replPrintValues ->
|
|
|
|
renderOutLn (Core.ppOut opts (toValue tab n))
|
|
|
|
| otherwise -> renderOutLn (Core.ppOut opts n)
|
|
|
|
where
|
|
|
|
compileThenEval :: ReplContext -> String -> Repl (Maybe Core.Node)
|
|
|
|
compileThenEval ctx s = compileString >>= mapM eval
|
|
|
|
where
|
|
|
|
artif :: Artifacts
|
|
|
|
artif = ctx ^. replContextArtifacts
|
|
|
|
|
|
|
|
eval :: Core.Node -> Repl Core.Node
|
|
|
|
eval n = do
|
2023-10-30 16:05:52 +03:00
|
|
|
ep <- getReplEntryPointFromPrepath (mkPrepath (toFilePath P.replPath))
|
2023-05-30 11:19:09 +03:00
|
|
|
let shouldDisambiguate :: Bool
|
2023-04-03 11:58:08 +03:00
|
|
|
shouldDisambiguate = not (opts ^. replNoDisambiguate)
|
2023-05-30 11:19:09 +03:00
|
|
|
(artif', n') <-
|
|
|
|
replFromEither
|
|
|
|
. run
|
|
|
|
. runReader ep
|
|
|
|
. runError @JuvixError
|
|
|
|
. runState artif
|
|
|
|
. runTransformations shouldDisambiguate (opts ^. replTransformations)
|
|
|
|
$ n
|
|
|
|
liftIO (doEvalIO' artif' n') >>= replFromEither
|
|
|
|
|
|
|
|
doEvalIO' :: Artifacts -> Core.Node -> IO (Either JuvixError Core.Node)
|
|
|
|
doEvalIO' artif' n =
|
|
|
|
mapLeft (JuvixError @Core.CoreError)
|
|
|
|
<$> doEvalIO False replDefaultLoc (artif' ^. artifactCoreTable) n
|
|
|
|
|
|
|
|
compileString :: Repl (Maybe Core.Node)
|
|
|
|
compileString = do
|
|
|
|
(artifacts, res) <- liftIO $ compileReplInputIO' ctx (strip (pack s))
|
|
|
|
res' <- replFromEither res
|
|
|
|
State.modify (over (replStateContext . _Just) (set replContextArtifacts artifacts))
|
|
|
|
return res'
|
|
|
|
|
|
|
|
core :: String -> Repl ()
|
|
|
|
core input = do
|
|
|
|
ctx <- replGetContext
|
|
|
|
opts <- Reader.asks (^. replOptions)
|
|
|
|
compileRes <- liftIO (compileReplInputIO' ctx (strip (pack input))) >>= replFromEither . snd
|
|
|
|
whenJust compileRes (renderOutLn . Core.ppOut opts)
|
|
|
|
|
2023-08-01 11:46:22 +03:00
|
|
|
dev :: String -> Repl ()
|
|
|
|
dev input = do
|
|
|
|
ctx <- replGetContext
|
|
|
|
if
|
|
|
|
| input == scoperStateCmd -> do
|
|
|
|
renderOutLn (Concrete.ppTrace (ctx ^. replContextArtifacts . artifactScoperState))
|
|
|
|
| otherwise ->
|
|
|
|
renderOutLn
|
|
|
|
( "Unrecognized command "
|
|
|
|
<> input
|
|
|
|
<> "\nAvailable commands: "
|
|
|
|
<> unwords cmds
|
|
|
|
)
|
|
|
|
where
|
|
|
|
cmds :: [String]
|
|
|
|
cmds = [scoperStateCmd]
|
|
|
|
scoperStateCmd :: String
|
|
|
|
scoperStateCmd = "scoperState"
|
|
|
|
|
2023-08-25 19:37:23 +03:00
|
|
|
ppConcrete :: (Concrete.PrettyPrint a) => a -> Repl AnsiText
|
2023-05-30 11:19:09 +03:00
|
|
|
ppConcrete a = do
|
|
|
|
gopts <- State.gets (^. replStateGlobalOptions)
|
|
|
|
let popts :: GenericOptions = project' gopts
|
|
|
|
return (Concrete.ppOut popts a)
|
|
|
|
|
2023-08-25 19:37:23 +03:00
|
|
|
printConcrete :: (Concrete.PrettyPrint a) => a -> Repl ()
|
2023-05-30 19:19:39 +03:00
|
|
|
printConcrete = ppConcrete >=> renderOut
|
2023-05-30 11:19:09 +03:00
|
|
|
|
2023-08-25 19:37:23 +03:00
|
|
|
printConcreteLn :: (Concrete.PrettyPrint a) => a -> Repl ()
|
2023-05-30 19:19:39 +03:00
|
|
|
printConcreteLn = ppConcrete >=> renderOutLn
|
|
|
|
|
|
|
|
replParseIdentifiers :: String -> Repl (NonEmpty Concrete.ScopedIden)
|
|
|
|
replParseIdentifiers input =
|
2023-05-30 11:19:09 +03:00
|
|
|
replExpressionUpToScopedAtoms (strip (pack input))
|
|
|
|
>>= getIdentifiers
|
|
|
|
where
|
|
|
|
getIdentifiers :: Concrete.ExpressionAtoms 'Concrete.Scoped -> Repl (NonEmpty Concrete.ScopedIden)
|
|
|
|
getIdentifiers as = mapM getIdentifier (as ^. Concrete.expressionAtoms)
|
|
|
|
where
|
|
|
|
getIdentifier :: Concrete.ExpressionAtom 'Concrete.Scoped -> Repl (Concrete.ScopedIden)
|
|
|
|
getIdentifier = \case
|
|
|
|
Concrete.AtomIdentifier a -> return a
|
|
|
|
Concrete.AtomParens p
|
|
|
|
| Concrete.ExpressionIdentifier a <- p -> return a
|
|
|
|
| Concrete.ExpressionParensIdentifier a <- p -> return a
|
|
|
|
_ -> err
|
|
|
|
where
|
|
|
|
err :: Repl a
|
2023-05-31 10:53:08 +03:00
|
|
|
err = replError (mkAnsiText @Text ":def expects one or more identifiers")
|
2023-05-30 11:19:09 +03:00
|
|
|
|
2023-05-30 19:19:39 +03:00
|
|
|
printDocumentation :: String -> Repl ()
|
|
|
|
printDocumentation = replParseIdentifiers >=> printIdentifiers
|
|
|
|
where
|
|
|
|
printIdentifiers :: NonEmpty Concrete.ScopedIden -> Repl ()
|
|
|
|
printIdentifiers (d :| ds) = do
|
|
|
|
printIdentifier d
|
|
|
|
whenJust (nonEmpty ds) $ \ds' -> replNewline >> printIdentifiers ds'
|
|
|
|
where
|
|
|
|
getInfoTable :: Repl Scoped.InfoTable
|
|
|
|
getInfoTable = (^. replContextArtifacts . artifactScopeTable) <$> replGetContext
|
|
|
|
|
|
|
|
printIdentifier :: Concrete.ScopedIden -> Repl ()
|
|
|
|
printIdentifier s = do
|
2023-08-25 16:28:58 +03:00
|
|
|
let n = s ^. Concrete.scopedIdenFinal . Scoped.nameId
|
2023-07-26 10:59:50 +03:00
|
|
|
mdoc <- case getNameKind s of
|
|
|
|
KNameAxiom -> getDocAxiom n
|
|
|
|
KNameInductive -> getDocInductive n
|
|
|
|
KNameLocal -> return Nothing
|
|
|
|
KNameFunction -> getDocFunction n
|
|
|
|
KNameConstructor -> getDocConstructor n
|
|
|
|
KNameLocalModule -> impossible
|
|
|
|
KNameTopModule -> impossible
|
2023-08-25 16:28:58 +03:00
|
|
|
KNameAlias -> impossible
|
User-friendly operator declaration syntax (#2270)
* Closes #1964
Adds the possibility to define operator fixities. They live in a
separate namespace. Standard library defines a few in
`Stdlib.Data.Fixity`:
```
syntax fixity rapp {arity: binary, assoc: right};
syntax fixity lapp {arity: binary, assoc: left, same: rapp};
syntax fixity seq {arity: binary, assoc: left, above: [lapp]};
syntax fixity functor {arity: binary, assoc: right};
syntax fixity logical {arity: binary, assoc: right, above: [seq]};
syntax fixity comparison {arity: binary, assoc: none, above: [logical]};
syntax fixity pair {arity: binary, assoc: right};
syntax fixity cons {arity: binary, assoc: right, above: [pair]};
syntax fixity step {arity: binary, assoc: right};
syntax fixity range {arity: binary, assoc: right, above: [step]};
syntax fixity additive {arity: binary, assoc: left, above: [comparison, range, cons]};
syntax fixity multiplicative {arity: binary, assoc: left, above: [additive]};
syntax fixity composition {arity: binary, assoc: right, above: [multiplicative]};
```
The fixities are identifiers in a separate namespace (different from
symbol and module namespaces). They can be exported/imported and then
used in operator declarations:
```
import Stdlib.Data.Fixity open;
syntax operator && logical;
syntax operator || logical;
syntax operator + additive;
syntax operator * multiplicative;
```
2023-08-09 19:15:51 +03:00
|
|
|
KNameFixity -> impossible
|
2023-05-30 19:19:39 +03:00
|
|
|
printDoc mdoc
|
|
|
|
where
|
|
|
|
printDoc :: Maybe (Concrete.Judoc 'Concrete.Scoped) -> Repl ()
|
|
|
|
printDoc = \case
|
|
|
|
Nothing -> do
|
2023-11-03 14:51:45 +03:00
|
|
|
let s' :: Doc Ann = pretty s
|
|
|
|
msg = "No documentation available for" <+> s'
|
|
|
|
renderOutLn (toAnsiText True msg)
|
2023-05-30 19:19:39 +03:00
|
|
|
Just ju -> printConcrete ju
|
|
|
|
|
|
|
|
getDocFunction :: Scoped.NameId -> Repl (Maybe (Concrete.Judoc 'Concrete.Scoped))
|
|
|
|
getDocFunction fun = do
|
|
|
|
tbl :: Scoped.InfoTable <- getInfoTable
|
|
|
|
let def :: Scoped.FunctionInfo = tbl ^?! Scoped.infoFunctions . at fun . _Just
|
2023-07-10 20:57:55 +03:00
|
|
|
return (def ^. Scoped.functionInfoDoc)
|
2023-05-30 19:19:39 +03:00
|
|
|
|
|
|
|
getDocInductive :: Scoped.NameId -> Repl (Maybe (Concrete.Judoc 'Concrete.Scoped))
|
|
|
|
getDocInductive ind = do
|
|
|
|
tbl :: Scoped.InfoTable <- (^. replContextArtifacts . artifactScopeTable) <$> replGetContext
|
|
|
|
let def :: Concrete.InductiveDef 'Concrete.Scoped = tbl ^?! Scoped.infoInductives . at ind . _Just . Scoped.inductiveInfoDef
|
|
|
|
return (def ^. Concrete.inductiveDoc)
|
|
|
|
|
|
|
|
getDocAxiom :: Scoped.NameId -> Repl (Maybe (Concrete.Judoc 'Concrete.Scoped))
|
|
|
|
getDocAxiom ax = do
|
|
|
|
tbl :: Scoped.InfoTable <- (^. replContextArtifacts . artifactScopeTable) <$> replGetContext
|
|
|
|
let def :: Concrete.AxiomDef 'Concrete.Scoped = tbl ^?! Scoped.infoAxioms . at ax . _Just . Scoped.axiomInfoDef
|
|
|
|
return (def ^. Concrete.axiomDoc)
|
|
|
|
|
|
|
|
getDocConstructor :: Scoped.NameId -> Repl (Maybe (Concrete.Judoc 'Concrete.Scoped))
|
|
|
|
getDocConstructor c = do
|
|
|
|
tbl :: Scoped.InfoTable <- (^. replContextArtifacts . artifactScopeTable) <$> replGetContext
|
|
|
|
let def :: Scoped.ConstructorInfo = tbl ^?! Scoped.infoConstructors . at c . _Just
|
|
|
|
return (def ^. Scoped.constructorInfoDef . Concrete.constructorDoc)
|
|
|
|
|
|
|
|
printDefinition :: String -> Repl ()
|
|
|
|
printDefinition = replParseIdentifiers >=> printIdentifiers
|
|
|
|
where
|
2023-05-30 11:19:09 +03:00
|
|
|
printIdentifiers :: NonEmpty Concrete.ScopedIden -> Repl ()
|
|
|
|
printIdentifiers (d :| ds) = do
|
|
|
|
printIdentifier d
|
|
|
|
whenJust (nonEmpty ds) $ \ds' -> replNewline >> printIdentifiers ds'
|
|
|
|
where
|
|
|
|
getInfoTable :: Repl Scoped.InfoTable
|
|
|
|
getInfoTable = (^. replContextArtifacts . artifactScopeTable) <$> replGetContext
|
|
|
|
|
|
|
|
printIdentifier :: Concrete.ScopedIden -> Repl ()
|
2023-07-26 10:59:50 +03:00
|
|
|
printIdentifier s =
|
2023-08-25 16:28:58 +03:00
|
|
|
let n = s ^. Concrete.scopedIdenFinal . Scoped.nameId
|
2023-07-26 10:59:50 +03:00
|
|
|
in case getNameKind s of
|
|
|
|
KNameAxiom -> printAxiom n
|
|
|
|
KNameInductive -> printInductive n
|
|
|
|
KNameLocal -> return ()
|
|
|
|
KNameFunction -> printFunction n
|
|
|
|
KNameConstructor -> printConstructor n
|
|
|
|
KNameLocalModule -> impossible
|
|
|
|
KNameTopModule -> impossible
|
User-friendly operator declaration syntax (#2270)
* Closes #1964
Adds the possibility to define operator fixities. They live in a
separate namespace. Standard library defines a few in
`Stdlib.Data.Fixity`:
```
syntax fixity rapp {arity: binary, assoc: right};
syntax fixity lapp {arity: binary, assoc: left, same: rapp};
syntax fixity seq {arity: binary, assoc: left, above: [lapp]};
syntax fixity functor {arity: binary, assoc: right};
syntax fixity logical {arity: binary, assoc: right, above: [seq]};
syntax fixity comparison {arity: binary, assoc: none, above: [logical]};
syntax fixity pair {arity: binary, assoc: right};
syntax fixity cons {arity: binary, assoc: right, above: [pair]};
syntax fixity step {arity: binary, assoc: right};
syntax fixity range {arity: binary, assoc: right, above: [step]};
syntax fixity additive {arity: binary, assoc: left, above: [comparison, range, cons]};
syntax fixity multiplicative {arity: binary, assoc: left, above: [additive]};
syntax fixity composition {arity: binary, assoc: right, above: [multiplicative]};
```
The fixities are identifiers in a separate namespace (different from
symbol and module namespaces). They can be exported/imported and then
used in operator declarations:
```
import Stdlib.Data.Fixity open;
syntax operator && logical;
syntax operator || logical;
syntax operator + additive;
syntax operator * multiplicative;
```
2023-08-09 19:15:51 +03:00
|
|
|
KNameFixity -> impossible
|
2023-08-25 16:28:58 +03:00
|
|
|
KNameAlias -> impossible
|
2023-05-30 11:19:09 +03:00
|
|
|
where
|
2023-08-25 19:37:23 +03:00
|
|
|
printLocation :: (HasLoc s) => s -> Repl ()
|
2023-05-30 11:19:09 +03:00
|
|
|
printLocation def = do
|
|
|
|
s' <- ppConcrete s
|
|
|
|
let txt :: Text = " is " <> prettyText (nameKindWithArticle (getNameKind s)) <> " defined at " <> prettyText (getLoc def)
|
2023-05-31 10:53:08 +03:00
|
|
|
renderOutLn (s' <> mkAnsiText txt)
|
2023-05-30 11:19:09 +03:00
|
|
|
|
|
|
|
printFunction :: Scoped.NameId -> Repl ()
|
|
|
|
printFunction fun = do
|
|
|
|
tbl :: Scoped.InfoTable <- getInfoTable
|
2023-10-12 19:59:47 +03:00
|
|
|
case tbl ^. Scoped.infoFunctions . at fun of
|
|
|
|
Just def -> do
|
|
|
|
printLocation def
|
|
|
|
printConcreteLn def
|
|
|
|
Nothing -> return ()
|
2023-05-30 11:19:09 +03:00
|
|
|
|
|
|
|
printInductive :: Scoped.NameId -> Repl ()
|
|
|
|
printInductive ind = do
|
|
|
|
tbl :: Scoped.InfoTable <- (^. replContextArtifacts . artifactScopeTable) <$> replGetContext
|
|
|
|
let def :: Concrete.InductiveDef 'Concrete.Scoped = tbl ^?! Scoped.infoInductives . at ind . _Just . Scoped.inductiveInfoDef
|
|
|
|
printLocation def
|
2023-05-30 19:19:39 +03:00
|
|
|
printConcreteLn def
|
2023-05-30 11:19:09 +03:00
|
|
|
|
|
|
|
printAxiom :: Scoped.NameId -> Repl ()
|
|
|
|
printAxiom ax = do
|
|
|
|
tbl :: Scoped.InfoTable <- (^. replContextArtifacts . artifactScopeTable) <$> replGetContext
|
|
|
|
let def :: Concrete.AxiomDef 'Concrete.Scoped = tbl ^?! Scoped.infoAxioms . at ax . _Just . Scoped.axiomInfoDef
|
|
|
|
printLocation def
|
2023-05-30 19:19:39 +03:00
|
|
|
printConcreteLn def
|
2023-05-30 11:19:09 +03:00
|
|
|
|
|
|
|
printConstructor :: Scoped.NameId -> Repl ()
|
|
|
|
printConstructor c = do
|
|
|
|
tbl :: Scoped.InfoTable <- (^. replContextArtifacts . artifactScopeTable) <$> replGetContext
|
|
|
|
let ind :: Scoped.Symbol = tbl ^?! Scoped.infoConstructors . at c . _Just . Scoped.constructorInfoTypeName
|
|
|
|
printInductive (ind ^. Scoped.nameId)
|
|
|
|
|
|
|
|
inferType :: String -> Repl ()
|
|
|
|
inferType input = do
|
|
|
|
gopts <- State.gets (^. replStateGlobalOptions)
|
|
|
|
n <- replExpressionUpToTyped (strip (pack input))
|
|
|
|
renderOutLn (Internal.ppOut (project' @GenericOptions gopts) (n ^. Internal.typedType))
|
|
|
|
|
2023-08-01 11:46:22 +03:00
|
|
|
replCommands :: ReplOptions -> [(String, String -> Repl ())]
|
|
|
|
replCommands opts = catchable ++ nonCatchable
|
2023-05-30 11:19:09 +03:00
|
|
|
where
|
|
|
|
nonCatchable :: [(String, String -> Repl ())]
|
|
|
|
nonCatchable =
|
|
|
|
[ ("quit", quit)
|
|
|
|
]
|
|
|
|
catchable :: [(String, String -> Repl ())]
|
|
|
|
catchable =
|
|
|
|
map
|
|
|
|
(second (catchAll .))
|
2023-08-01 11:46:22 +03:00
|
|
|
[ ("help", const (printHelpTxt opts)),
|
2022-11-07 16:47:56 +03:00
|
|
|
-- `multiline` is included here for auto-completion purposes only.
|
|
|
|
-- `repline`'s `multilineCommand` logic overrides this no-op.
|
2023-05-30 11:19:09 +03:00
|
|
|
(multilineCmd, const (return ())),
|
|
|
|
("load", loadFile . pSomeFile),
|
|
|
|
("reload", reloadFile),
|
2022-11-07 16:47:56 +03:00
|
|
|
("root", printRoot),
|
2023-05-30 11:19:09 +03:00
|
|
|
("def", printDefinition),
|
2023-05-30 19:19:39 +03:00
|
|
|
("doc", printDocumentation),
|
2022-11-07 16:47:56 +03:00
|
|
|
("type", inferType),
|
2022-11-07 20:43:30 +03:00
|
|
|
("version", displayVersion),
|
2023-08-01 11:46:22 +03:00
|
|
|
("core", core),
|
|
|
|
("dev", dev)
|
2022-11-07 16:47:56 +03:00
|
|
|
]
|
|
|
|
|
2023-05-30 11:19:09 +03:00
|
|
|
catchAll :: Repl () -> Repl ()
|
|
|
|
catchAll = Repline.dontCrash . catchJuvixError
|
|
|
|
where
|
|
|
|
catchJuvixError :: Repl () -> Repl ()
|
|
|
|
catchJuvixError (HaskelineT m) = HaskelineT (mapInputT_ catchErrorS m)
|
|
|
|
where
|
|
|
|
catchErrorS :: ReplS () -> ReplS ()
|
|
|
|
catchErrorS = (`Except.catchError` printErrorS)
|
|
|
|
|
|
|
|
defaultMatcher :: [(String, CompletionFunc ReplS)]
|
|
|
|
defaultMatcher = [(":load", fileCompleter)]
|
|
|
|
|
|
|
|
optsCompleter :: WordCompleter ReplS
|
|
|
|
optsCompleter n = do
|
2023-08-01 11:46:22 +03:00
|
|
|
opts <- Reader.asks (^. replOptions)
|
|
|
|
let names = (":" <>) . fst <$> replCommands opts
|
2023-05-30 11:19:09 +03:00
|
|
|
return (filter (isPrefixOf n) names)
|
|
|
|
|
|
|
|
replBanner :: MultiLine -> Repl String
|
|
|
|
replBanner = \case
|
|
|
|
MultiLine -> return "... "
|
|
|
|
SingleLine -> do
|
|
|
|
mmodulePath <-
|
|
|
|
State.gets
|
|
|
|
( ^?
|
|
|
|
replStateContext
|
|
|
|
. _Just
|
|
|
|
. replContextArtifacts
|
|
|
|
. artifactMainModuleScope
|
|
|
|
. _Just
|
|
|
|
. scopePath
|
|
|
|
. absTopModulePath
|
|
|
|
)
|
|
|
|
return $ case mmodulePath of
|
|
|
|
Just path -> [i|#{unpack (P.prettyText path)}> |]
|
|
|
|
Nothing -> "juvix> "
|
|
|
|
|
|
|
|
replPrefix :: Maybe Char
|
|
|
|
replPrefix = Just ':'
|
|
|
|
|
|
|
|
replMultilineCommand :: Maybe String
|
|
|
|
replMultilineCommand = Just multilineCmd
|
|
|
|
|
|
|
|
replInitialiser :: Repl ()
|
|
|
|
replInitialiser = do
|
|
|
|
gopts <- State.gets (^. replStateGlobalOptions)
|
|
|
|
opts <- Reader.asks (^. replOptions)
|
|
|
|
welcomeMsg
|
|
|
|
unless
|
|
|
|
(opts ^. replNoPrelude || gopts ^. globalNoStdlib)
|
|
|
|
(maybe loadDefaultPrelude (loadFile . (^. pathPath)) (opts ^. replInputFile))
|
|
|
|
|
|
|
|
replFinaliser :: Repl ExitDecision
|
|
|
|
replFinaliser = return Exit
|
|
|
|
|
|
|
|
replTabComplete :: CompleterStyle ReplS
|
|
|
|
replTabComplete = Prefix (wordCompleter optsCompleter) defaultMatcher
|
|
|
|
|
|
|
|
printRoot :: String -> Repl ()
|
|
|
|
printRoot _ = do
|
2023-10-30 16:05:52 +03:00
|
|
|
r <- State.gets (^. replStateRoot . rootRootDir)
|
2023-05-30 11:19:09 +03:00
|
|
|
liftIO $ putStrLn (pack (toFilePath r))
|
|
|
|
|
2023-08-25 19:37:23 +03:00
|
|
|
runCommand :: (Members '[Embed IO, App] r) => ReplOptions -> Sem r ()
|
2023-05-30 11:19:09 +03:00
|
|
|
runCommand opts = do
|
2023-10-30 16:05:52 +03:00
|
|
|
root <- askRoot
|
2023-05-30 11:19:09 +03:00
|
|
|
let replAction :: ReplS ()
|
2022-12-20 15:05:40 +03:00
|
|
|
replAction = do
|
|
|
|
evalReplOpts
|
|
|
|
ReplOpts
|
2023-05-30 11:19:09 +03:00
|
|
|
{ prefix = replPrefix,
|
|
|
|
multilineCommand = replMultilineCommand,
|
|
|
|
initialiser = replInitialiser,
|
|
|
|
finaliser = replFinaliser,
|
|
|
|
tabComplete = replTabComplete,
|
|
|
|
command = replCommand opts,
|
2023-08-01 11:46:22 +03:00
|
|
|
options = replCommands opts,
|
2023-05-30 11:19:09 +03:00
|
|
|
banner = replBanner
|
2022-12-20 15:05:40 +03:00
|
|
|
}
|
2022-11-07 16:47:56 +03:00
|
|
|
globalOptions <- askGlobalOptions
|
2023-05-30 11:19:09 +03:00
|
|
|
let env =
|
|
|
|
ReplEnv
|
2023-10-30 16:05:52 +03:00
|
|
|
{ _replRoot = root,
|
2023-05-30 11:19:09 +03:00
|
|
|
_replOptions = opts
|
|
|
|
}
|
|
|
|
iniState =
|
|
|
|
ReplState
|
2023-10-30 16:05:52 +03:00
|
|
|
{ _replStateRoot = root,
|
2023-05-30 11:19:09 +03:00
|
|
|
_replStateContext = Nothing,
|
|
|
|
_replStateGlobalOptions = globalOptions
|
|
|
|
}
|
|
|
|
e <-
|
|
|
|
embed
|
|
|
|
. Except.runExceptT
|
|
|
|
. (`State.evalStateT` iniState)
|
|
|
|
. (`Reader.runReaderT` env)
|
|
|
|
$ replAction
|
|
|
|
case e of
|
|
|
|
Left {} -> error "impossible: uncaught exception"
|
|
|
|
Right () -> return ()
|
2022-11-07 16:47:56 +03:00
|
|
|
|
2023-04-13 12:27:39 +03:00
|
|
|
-- | If the package contains the stdlib as a dependency, loads the Prelude
|
|
|
|
defaultPreludeEntryPoint :: Repl (Maybe EntryPoint)
|
2022-11-10 14:26:38 +03:00
|
|
|
defaultPreludeEntryPoint = do
|
2023-10-30 16:05:52 +03:00
|
|
|
root <- State.gets (^. replStateRoot)
|
2023-11-07 21:11:02 +03:00
|
|
|
let buildRoot = root ^. rootRootDir
|
|
|
|
buildDir = resolveAbsBuildDir buildRoot (root ^. rootBuildDir)
|
2023-10-30 16:05:52 +03:00
|
|
|
pkg = root ^. rootPackage
|
|
|
|
mstdlibPath <- liftIO (runM (runFilesIO (packageStdlib buildRoot buildDir (pkg ^. packageDependencies))))
|
2023-04-19 17:56:48 +03:00
|
|
|
case mstdlibPath of
|
2023-04-13 12:27:39 +03:00
|
|
|
Just stdlibPath ->
|
2023-09-05 18:11:17 +03:00
|
|
|
Just
|
|
|
|
. set entryPointResolverRoot stdlibPath
|
2023-10-30 16:05:52 +03:00
|
|
|
<$> getReplEntryPointFromPath (stdlibPath <//> P.preludePath)
|
2023-04-19 17:56:48 +03:00
|
|
|
Nothing -> return Nothing
|
2022-11-10 14:26:38 +03:00
|
|
|
|
2022-12-20 15:05:40 +03:00
|
|
|
replMakeAbsolute :: SomeBase b -> Repl (Path Abs b)
|
|
|
|
replMakeAbsolute = \case
|
|
|
|
Abs p -> return p
|
|
|
|
Rel r -> do
|
2023-10-30 16:05:52 +03:00
|
|
|
invokeDir <- State.gets (^. replStateRoot . rootInvokeDir)
|
2022-12-20 15:05:40 +03:00
|
|
|
return (invokeDir <//> r)
|
2022-11-07 16:47:56 +03:00
|
|
|
|
2023-05-30 11:19:09 +03:00
|
|
|
replExpressionUpToScopedAtoms :: Text -> Repl (Concrete.ExpressionAtoms 'Concrete.Scoped)
|
|
|
|
replExpressionUpToScopedAtoms txt = do
|
|
|
|
ctx <- replGetContext
|
|
|
|
x <-
|
|
|
|
liftIO
|
|
|
|
. runM
|
|
|
|
. runError
|
|
|
|
. evalState (ctx ^. replContextArtifacts)
|
|
|
|
. runReader (ctx ^. replContextEntryPoint)
|
2023-10-30 16:05:52 +03:00
|
|
|
$ expressionUpToAtomsScoped P.replPath txt
|
2023-05-30 11:19:09 +03:00
|
|
|
replFromEither x
|
|
|
|
|
|
|
|
replExpressionUpToTyped :: Text -> Repl Internal.TypedExpression
|
|
|
|
replExpressionUpToTyped txt = do
|
|
|
|
ctx <- replGetContext
|
|
|
|
x <-
|
|
|
|
liftIO
|
|
|
|
. runM
|
|
|
|
. runError
|
|
|
|
. evalState (ctx ^. replContextArtifacts)
|
|
|
|
. runReader (ctx ^. replContextEntryPoint)
|
2023-10-30 16:05:52 +03:00
|
|
|
$ expressionUpToTyped P.replPath txt
|
2023-05-30 11:19:09 +03:00
|
|
|
replFromEither x
|
2022-11-07 16:47:56 +03:00
|
|
|
|
2023-05-08 13:23:15 +03:00
|
|
|
compileReplInputIO' :: ReplContext -> Text -> IO (Artifacts, (Either JuvixError (Maybe Core.Node)))
|
|
|
|
compileReplInputIO' ctx txt =
|
2023-03-30 14:39:27 +03:00
|
|
|
runM
|
2023-05-08 13:23:15 +03:00
|
|
|
. runState (ctx ^. replContextArtifacts)
|
|
|
|
. runReader (ctx ^. replContextEntryPoint)
|
|
|
|
$ do
|
2023-10-30 16:05:52 +03:00
|
|
|
r <- compileReplInputIO P.replPath txt
|
2023-05-08 13:23:15 +03:00
|
|
|
return (extractNode <$> r)
|
|
|
|
where
|
|
|
|
extractNode :: ReplPipelineResult -> Maybe Core.Node
|
|
|
|
extractNode = \case
|
|
|
|
ReplPipelineResultNode n -> Just n
|
|
|
|
ReplPipelineResultImport {} -> Nothing
|
2023-10-03 00:13:45 +03:00
|
|
|
ReplPipelineResultOpen {} -> Nothing
|
2022-11-07 16:47:56 +03:00
|
|
|
|
2022-11-10 14:26:38 +03:00
|
|
|
render' :: (P.HasAnsiBackend a, P.HasTextBackend a) => a -> Repl ()
|
|
|
|
render' t = do
|
|
|
|
opts <- State.gets (^. replStateGlobalOptions)
|
|
|
|
hasAnsi <- liftIO (Ansi.hSupportsANSIColor stdout)
|
|
|
|
liftIO (P.renderIO (not (opts ^. globalNoColors) && hasAnsi) t)
|
2022-11-07 16:47:56 +03:00
|
|
|
|
2023-05-30 11:19:09 +03:00
|
|
|
replNewline :: Repl ()
|
|
|
|
replNewline = liftIO (putStrLn "")
|
|
|
|
|
2022-11-10 14:26:38 +03:00
|
|
|
renderOut :: (P.HasAnsiBackend a, P.HasTextBackend a) => a -> Repl ()
|
2023-05-30 11:19:09 +03:00
|
|
|
renderOut = render'
|
|
|
|
|
|
|
|
renderOutLn :: (P.HasAnsiBackend a, P.HasTextBackend a) => a -> Repl ()
|
|
|
|
renderOutLn t = renderOut t >> replNewline
|
2022-11-07 16:47:56 +03:00
|
|
|
|
2023-05-30 11:19:09 +03:00
|
|
|
printErrorS :: JuvixError -> ReplS ()
|
|
|
|
printErrorS e = do
|
2022-11-10 14:26:38 +03:00
|
|
|
opts <- State.gets (^. replStateGlobalOptions)
|
|
|
|
hasAnsi <- liftIO (Ansi.hSupportsANSIColor stderr)
|
2022-11-07 16:47:56 +03:00
|
|
|
liftIO $ hPutStrLn stderr $ run (runReader (project' @GenericOptions opts) (Error.render (not (opts ^. globalNoColors) && hasAnsi) False e))
|
2023-03-30 14:39:27 +03:00
|
|
|
|
|
|
|
runTransformations ::
|
2023-04-03 11:58:08 +03:00
|
|
|
forall r.
|
2023-08-25 19:37:23 +03:00
|
|
|
(Members '[State Artifacts, Error JuvixError, Reader EntryPoint] r) =>
|
2023-04-03 11:58:08 +03:00
|
|
|
Bool ->
|
2023-03-30 14:39:27 +03:00
|
|
|
[Core.TransformationId] ->
|
|
|
|
Core.Node ->
|
|
|
|
Sem r Core.Node
|
2023-04-03 11:58:08 +03:00
|
|
|
runTransformations shouldDisambiguate ts n = runCoreInfoTableBuilderArtifacts $ do
|
|
|
|
sym <- addNode n
|
|
|
|
applyTransforms shouldDisambiguate ts
|
|
|
|
getNode sym
|
|
|
|
where
|
|
|
|
addNode :: Core.Node -> Sem (Core.InfoTableBuilder ': r) Core.Symbol
|
|
|
|
addNode node = do
|
|
|
|
sym <- Core.freshSymbol
|
|
|
|
Core.registerIdentNode sym node
|
|
|
|
-- `n` will get filtered out by the transformations unless it has a
|
|
|
|
-- corresponding entry in `infoIdentifiers`
|
|
|
|
tab <- Core.getInfoTable
|
|
|
|
let name = Core.freshIdentName tab "_repl"
|
|
|
|
idenInfo =
|
|
|
|
Core.IdentifierInfo
|
|
|
|
{ _identifierName = name,
|
|
|
|
_identifierSymbol = sym,
|
|
|
|
_identifierLocation = Nothing,
|
|
|
|
_identifierArgsNum = 0,
|
|
|
|
_identifierType = Core.mkDynamic',
|
|
|
|
_identifierIsExported = False,
|
2023-04-26 16:26:13 +03:00
|
|
|
_identifierBuiltin = Nothing,
|
2023-06-01 18:36:47 +03:00
|
|
|
_identifierPragmas = mempty,
|
|
|
|
_identifierArgNames = []
|
2023-04-03 11:58:08 +03:00
|
|
|
}
|
|
|
|
Core.registerIdent name idenInfo
|
|
|
|
return sym
|
|
|
|
|
|
|
|
applyTransforms :: Bool -> [Core.TransformationId] -> Sem (Core.InfoTableBuilder ': r) ()
|
|
|
|
applyTransforms shouldDisambiguate' ts' = do
|
|
|
|
tab <- Core.getInfoTable
|
|
|
|
tab' <- mapReader Core.fromEntryPoint $ Core.applyTransformations ts' tab
|
|
|
|
let tab'' =
|
|
|
|
if
|
|
|
|
| shouldDisambiguate' -> disambiguateNames tab'
|
|
|
|
| otherwise -> tab'
|
|
|
|
Core.setInfoTable tab''
|
|
|
|
|
|
|
|
getNode :: Core.Symbol -> Sem (Core.InfoTableBuilder ': r) Core.Node
|
2023-04-04 19:58:05 +03:00
|
|
|
getNode sym = fromMaybe impossible . flip Core.lookupIdentifierNode' sym <$> Core.getInfoTable
|