
SevenThunders wrote:
I have run into a baffling distinction between the behavior of GHCi and the compiled binary from GHC. I suspect it's something pretty stupid on my part.
I have the following test program
import Matrix main = let f1 = bRgauss 4 3 f2 = bRgauss 3 2 fu = f1 *. f2 in bsave "fumat" fu ---------------------------------- The type signature of bsave is
-- | save a matrix to a file bsave :: String -> m -> IO() bsave str z = do k <- matindx z withCString str (\x -> bmsave x k)
and bmsave is a C routine that does a simple write to disk using fprintf. If I compile using GHC and run this as test.exe it does absolutely nothing, no file is actually saved. In fact no file is saved even if I try to print components of fu in the IO monad.
Whereas if I load it into GHCi and run main, everything works as expected. Well sort of. Apparently everytime I extract something out of fu and use it in an IO monad it executes all the IO actions in fu, so it's easy to get unwanted behavior with incautious use.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
OK it was stupid. Apparently GHC behaves differently according to what the name of the high level source file is. If I renamed test.hc to main.hc everything works the same as GHCi. I probably should actually read the manual some day. -- View this message in context: http://www.nabble.com/Baffled-by-Disk-IO-tf2021760.html#a5559084 Sent from the Haskell - Haskell-Cafe forum at Nabble.com.