Home > Back-end >  Running a haskell program in the repl after changing the file
Running a haskell program in the repl after changing the file

Time:03-19

I have a haskell program that defines

module Lib
( someFunc
) where

 

someFunc :: IO ()
someFunc  = do
print "Hello world"

Opening the REPL with stack loads this lib into the context.

*Main Lib Paths_hs> someFunc
"Hello world"

After changing the function, writing the file, and executing the function i'm presented with the same result

someFunc :: IO ()
someFunc  = do
print "Bye bye"
*Main Lib Paths_hs> someFunc
"Hello world"

But i'm expecting the function someFunc to return the new value i've declared "Bye bye".

I've tried running stack build but to no avail.Now, I can re open the REPL, and have the new function, but I don't want to lose my current history. Is there anyway I can load my new compiled program into the current REPL, or load the active sessions history into a new REPL

CodePudding user response:

According to the docs, you can use the :reload directive (or :r shortly).

  • Related