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

@ -1,7 +1,6 @@
module FileEval where
import Eval
import Library
import Parser
import Research
@ -9,17 +8,23 @@ import System.IO
import qualified Data.Map as Map
evaluateFile :: FilePath -> IO T
evaluateFile filePath = do
evaluateFileResult :: FilePath -> IO T
evaluateFileResult filePath = do
contents <- readFile filePath
let asts = parseTricu contents
let finalEnv = evalTricu library asts
let finalEnv = evalTricu Map.empty asts
case Map.lookup "__result" finalEnv of
Just finalResult -> return finalResult
Nothing -> error "No result found in final environment"
evaluateFileEnv :: FilePath -> IO Env
evaluateFileEnv filePath = do
evaluateFile :: FilePath -> IO Env
evaluateFile filePath = do
contents <- readFile filePath
let asts = parseTricu contents
pure $ evalTricu library asts
pure $ evalTricu Map.empty asts
evaluateFileWithContext :: Env -> FilePath -> IO Env
evaluateFileWithContext env filePath = do
contents <- readFile filePath
let asts = parseTricu contents
pure $ evalTricu env asts