halive 0.1.6 → 0.1.8
raw patch · 4 files changed
+132/−22 lines, 4 files
Files
- ChangeLog.md +68/−0
- exec/HaliveMain.hs +1/−0
- halive.cabal +4/−2
- src/Halive/SubHalive.hs +59/−20
+ ChangeLog.md view
@@ -0,0 +1,68 @@+# Revision history for halive+## 0.1.8. -- 2021-03-26+* Re-enable -dynamic to fix rogue crashes with C-linking libraries (e.g. nanovg-hs, glfw)+* Add --compiled option+* -c flags, fix compiling profiled+* Fix CPP indentation (Manuel Bärenz)+* Compatibility with sdl2-2.5.* (Manuel Bärenz)++## 0.1.7. -- 2019-03-13+* Add colorized output++## 0.1.6. -- 2019-02-21+* Documentation updates+* O1 instead of O2 for compiled code++## 0.1.5. -- 2019-02-21+* Updates for GHC 8.6+* Updates for GHC 8.2 (Schell Scivally)+* Add "-c/--compiled" flag for faster code (traded for slower recompilation)++## 0.1.4. -- 2017-03-23+* Remove extraneous argument from compileExpression+* Fix change detection for editors that delete and recreate files rather than modifying them+* Ignores emacs flycheck/flymake and before-save files (Schell Scivally)+* Add ability to pass just file contents rather than an actual file+* Add ability to turn off language features (e.g. NoImplicitPrelude)+* Add liveExpression++## 0.1.3. -- 2017-02-24+* Allows Halive to be used in a nix environment (Jude Taylor)++## 0.1.2. -- 2017-01-02+* Restores ability for Halive to watch surrounding files in a dir+ (and lays groundwork to allow configuration of which filetypes are watched)++## 0.1.1. -- 2016-12-28+* GHC8 support+* Windows support+* Only restarts your program once all type errors are fixed.+* Halive-as-a-library, aka "SubHalive"+* halive exe now uses SubHalive as core.+* Add persistState utility to store/restore state in a State monad, for easily preserving program state across recompilations+* Prioritize stack's "local-pkg-db:" over "snapshot-pkg-db:" to allow overriding packages just as stack does+* Switch to SDL for demo+* Add the demo as a test-suite to manage its dependencies++## 0.1.0.7 -- 2015-08-12+* Implement support for stack projects++## 0.1.0.6 -- 2015-08-07+* Remove system-filepath++## 0.1.0.5 -- 2015-06-29+* 7.8 compatibility fix++## 0.1.0.4 -- 2015-06-23+* Add Halive.Concurrent to help with killing threads when restarting a program++## 0.1.0.2/0.1.0.3 -- 2015-06-20+* Add command line argument support (Jonathan Geddes)+* Fix compilation on Windows, although Halive doesn't actually work yet++## 0.1.0.1 -- 2015-05-26+* Compilation fix++## 0.1.0.0 -- 2015-05-26++* First version.
exec/HaliveMain.hs view
@@ -45,6 +45,7 @@ (defaultGHCSessionConfig { gscImportPaths = includeDirs , gscCompilationMode = if shouldCompile then Compiled else Interpreted+ , gscUseColor = True }) recompiler <- recompilerWithConfig ghc RecompilerConfig
halive.cabal view
@@ -1,5 +1,5 @@ name: halive-version: 0.1.6+version: 0.1.8 synopsis: A live recompiler description: Live recompiler for Haskell@@ -27,6 +27,8 @@ build-type: Simple cabal-version: >=1.10 +extra-source-files: ChangeLog.md+ source-repository head type: git location: git://github.com/lukexi/halive.git@@ -69,7 +71,7 @@ main-is: HaliveMain.hs hs-source-dirs: exec default-language: Haskell2010- -- ghc-prof-options: -dynamic -Wall -threaded -fprof-auto+ ghc-prof-options: -static -Wall -threaded -fprof-auto-exported ghc-options: -dynamic -Wall -threaded -optP-Wno-nonportable-include-path -- This strangely enables "-dynamic" for all dependent libraries, -- so I need to comment this during profiling?!?
src/Halive/SubHalive.hs view
@@ -27,6 +27,8 @@ import GHC.Paths import Outputable import StringBuffer+import PprColour+import qualified Util -- import Packages import Linker@@ -82,6 +84,7 @@ -- (which saves memory but slows compilation) -- or keeping it around for sequences of compilations -- (which lies in-between these)+ , gscUseColor :: Bool } defaultGHCSessionConfig :: GHCSessionConfig@@ -97,6 +100,7 @@ , gscVerbosity = 0 , gscMainThreadID = Nothing , gscKeepLibsInMemory = Always+ , gscUseColor = False } -- Starts up a GHC session and then runs the given action within it@@ -137,7 +141,11 @@ , stubDir = Just ".halive" , dumpDir = Just ".halive" , verbosity = gscVerbosity+ , useColor = if gscUseColor then Util.Always else Util.Never+ , canUseColor = gscUseColor+ , colScheme = defaultScheme })+ >>= (pure . (`gopt_set` Opt_DiagnosticsShowCaret)) -- turn off the GHCi sandbox -- since it breaks OpenGL/GUI usage >>= (pure . (`gopt_unset` Opt_GhciSandbox))@@ -281,27 +289,57 @@ return (Left (show _x)) ) --+-- Adapted from +-- https://hackage.haskell.org/package/ghc-8.2.1/docs/src/DynFlags.html#defaultLogAction logHandler :: IORef String -> LogAction-#if __GLASGOW_HASKELL__ >= 800-logHandler ref dflags _warnReason severity srcSpan style msg =-#else-logHandler ref dflags severity srcSpan style msg =-#endif- case severity of- SevError -> modifyIORef' ref (++ ('\n':messageWithLocation))- SevFatal -> modifyIORef' ref (++ ('\n':messageWithLocation))- SevWarning -> modifyIORef' ref (++ ('\n':messageWithLocation))- _ -> do- putStr messageOther- return () -- ignore the rest- where cntx = initSDocContext dflags style- locMsg = mkLocMessage severity srcSpan msg- messageWithLocation = show (runSDoc locMsg cntx)- messageOther = show (runSDoc msg cntx)+logHandler errorIORef dflags reason severity srcSpan style msg+ = case severity of+ SevOutput -> printOut msg style+ SevDump -> printOut (msg $$ blankLine) style+ SevInteractive -> putStrSDoc msg style+ SevInfo -> printErrs msg style+ SevFatal -> printErrs msg style+ _ -> do -- otherwise (i.e. SevError or SevWarning)+ caretDiagnostic <-+ if gopt Opt_DiagnosticsShowCaret dflags+ then getCaretDiagnostic severity srcSpan+ else pure empty+ writeToErrorIORef (message $+$ caretDiagnostic)+ (setStyleColoured True style)+ -- careful (#2302): printErrs prints in UTF-8,+ -- whereas converting to string first and using+ -- hPutStr would just emit the low 8 bits of+ -- each unicode char.+ where printOut = writeToErrorIORef+ printErrs = writeToErrorIORef+ putStrSDoc = writeToErrorIORef+ -- Pretty print the warning flag, if any (#10752)+ message = mkLocMessageAnn Nothing severity srcSpan msg+ writeToErrorIORef message style = + modifyIORef' errorIORef + (++ ('\n':renderWithStyle dflags message style)) +-- logHandler :: IORef String -> LogAction+-- #if __GLASGOW_HASKELL__ >= 800+-- logHandler ref dflags _warnReason severity srcSpan style msg =+-- #else+-- logHandler ref dflags severity srcSpan style msg =+-- #endif+-- caretDiagnostic <- getCaretDiagnostic dflags srcSpan+-- let cntx = initSDocContext dflags style+-- locMsg = mkLocMessage severity srcSpan msg+-- messageWithLocation = show (runSDoc locMsg cntx)+-- messageOther = show (runSDoc msg cntx)+-- renderWithStyle dflags (msg $+$ caretDiagnostic) +-- (setStyleColoured True style) +-- case severity of+-- SevError -> modifyIORef' ref (++ ('\n':messageWithLocation))+-- SevFatal -> modifyIORef' ref (++ ('\n':messageWithLocation))+-- SevWarning -> modifyIORef' ref (++ ('\n':messageWithLocation))+-- _ -> do+-- putStr messageOther+-- return () -- ignore the rest -- A helper from interactive-diagrams to print out GHC API values, -- useful while debugging the API.@@ -323,8 +361,9 @@ gatherErrors sourceError = do printException sourceError dflags <- getSessionDynFlags- let errorSDocs = pprErrMsgBagWithLoc (srcErrorMessages sourceError)- errorStrings = map (showSDoc dflags) errorSDocs+ let style = mkUserStyle dflags neverQualify AllTheWay+ errorSDocs = pprErrMsgBagWithLoc (srcErrorMessages sourceError)+ errorStrings = map (showSDocForUser dflags neverQualify) errorSDocs return (concat errorStrings)