Provide "library" via tricu file directly

Allows easier loading of other files and drops the list of Haskell
strings containing the basic tools included
This commit is contained in:
James Eversole
2025-01-01 18:53:56 -06:00
parent 39be66a4d1
commit a2c459b148
7 changed files with 80 additions and 64 deletions

View File

@ -2,11 +2,11 @@ module Main where
import Eval (evalTricu, result)
import FileEval
import Library (library)
import Parser (parseTricu)
import REPL
import Research
import Control.Monad.IO.Class (liftIO)
import Text.Megaparsec (runParser)
import System.Console.CmdArgs
@ -68,10 +68,11 @@ main = do
Repl -> do
putStrLn "Welcome to the tricu REPL"
putStrLn "You can exit with `CTRL+D` or the `:_exit` command.`"
library <- liftIO $ evaluateFile "./lib/base.tri"
repl library
Evaluate { file = maybeFilePath, output = maybeOutputPath, form = form } -> do
result <- case maybeFilePath of
Just filePath -> evaluateFile filePath
Just filePath -> evaluateFileResult filePath
Nothing -> do
t <- getContents
pure $ runTricu t
@ -85,6 +86,7 @@ main = do
value <- case maybeFilePath of
Just filePath -> readFile filePath
Nothing -> getContents
library <- liftIO $ evaluateFile "./lib/base.tri"
putStrLn $ decodeResult $ result $ evalTricu library $ parseTricu value
runTricu :: String -> T