Tricu 2.0.0
Sorry for squashing all of this but 🤷
This commit is contained in:
42
src/Check.hs
Normal file
42
src/Check.hs
Normal file
@@ -0,0 +1,42 @@
|
||||
module Check
|
||||
( module Check.Core
|
||||
, module Check.IO
|
||||
, checkFile
|
||||
, checkFileWithStore
|
||||
, checkSource
|
||||
) where
|
||||
|
||||
import Check.Core
|
||||
import Check.IO
|
||||
import ContentStore (ObjectRef, StorePath, getViewType)
|
||||
import Eval (evalTricu)
|
||||
import FileEval (LoadedSource(..), defaultStorePath, evaluateFile, evaluateFileWithStore, loadFileWithStore)
|
||||
import Research (Env, ViewType)
|
||||
|
||||
import qualified Data.Map as Map
|
||||
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
|
||||
checkFile :: FilePath -> IO String
|
||||
checkFile path = do
|
||||
store <- defaultStorePath
|
||||
checkFileWithStore store path
|
||||
|
||||
checkFileWithStore :: StorePath -> FilePath -> IO String
|
||||
checkFileWithStore store path = do
|
||||
loaded <- loadFileWithStore store path
|
||||
viewEnv <- evaluateFileWithStore (Just store) "./lib/view.tri"
|
||||
let baseEnv = Map.union viewEnv (loadedImports loaded)
|
||||
checkerEnv = evalTricu baseEnv (loadedAst loaded)
|
||||
imports <- importedViewsFromResolvedModulesEither (loadImportedView store) (loadedModules loaded)
|
||||
checkProgramWithEnvAndImportedViews checkerEnv imports (loadedAst loaded)
|
||||
|
||||
viewCheckerEnv :: Env
|
||||
viewCheckerEnv = unsafePerformIO (evaluateFile "./lib/view.tri")
|
||||
{-# NOINLINE viewCheckerEnv #-}
|
||||
|
||||
checkSource :: String -> IO String
|
||||
checkSource = checkSourceWithEnv viewCheckerEnv
|
||||
|
||||
loadImportedView :: StorePath -> ObjectRef -> IO (Either String ViewType)
|
||||
loadImportedView = getViewType
|
||||
Reference in New Issue
Block a user