projects
/
kaleidoscope-hs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Generate the module inside the repl
[kaleidoscope-hs.git]
/
Utils.hs
diff --git
a/Utils.hs
b/Utils.hs
index 2a83c3591276ea116a969301fd4f24ae772af949..3bd3b37e01e54274cf4841b52e18d8d4b2cea97e 100644
(file)
--- a/
Utils.hs
+++ b/
Utils.hs
@@
-4,11
+4,18
@@
Shoving away gross stuff into this one module.
module Utils where
import Control.Monad.Trans.State
module Utils where
import Control.Monad.Trans.State
+import Data.ByteString.Short (ShortByteString)
import Data.Functor.Identity
import LLVM.AST
import LLVM.IRBuilder.Module
import LLVM.IRBuilder.Internal.SnocList
import Data.Functor.Identity
import LLVM.AST
import LLVM.IRBuilder.Module
import LLVM.IRBuilder.Internal.SnocList
+moduleSoFar :: MonadModuleBuilder m => ShortByteString -> m Module
+moduleSoFar nm = do
+ s <- liftModuleState get
+ let ds = getSnocList (builderDefs s)
+ return $ defaultModule { moduleName = nm, moduleDefinitions = ds }
+
mostRecentDef :: Monad m => ModuleBuilderT m Definition
mostRecentDef = last . getSnocList . builderDefs <$> liftModuleState get
mostRecentDef :: Monad m => ModuleBuilderT m Definition
mostRecentDef = last . getSnocList . builderDefs <$> liftModuleState get