:l shell.hs :def shell (\s -> do shell s; return "") :l :shell echo module A where {} >A.hs :shell echo module B where { import A } >B.hs -- Workaround for #16201. We use "touch -r" to set modification -- timestamps, which leads to precision loss on Darwin. For example, -- -- before: 2019-02-25 01:11:23.807627350 +0300 -- after: 2019-02-25 01:11:23.807627000 +0300 -- ^^^ -- This means we can't trick GHCi into thinking the file hasn't been changed -- by restoring its old timestamp, as we cannot faithfully restore all digits. -- -- The solution is to nullify the insignificant digits before the first load. :shell touch -r B.hs B.hs :load B -- We're going to replace B.hs with an invalid module but without -- changing its timestamp. A :reload should look at the contents of the -- file, because the hash has changed. Note that this test previously tested -- for the opposite behaviour, but was changed as a result of #19439 / #16495. :shell cp B.hs B.hs-copy :shell touch -r B.hs B.hs-copy :shell echo "*** INVALID ***" >B.hs :shell touch -r B.hs-copy B.hs :reload -- Put the original file back, now it should work :shell cp B.hs-copy B.hs :reload