Closed
Description
Reading a file at compile time via TH worked before #1450, but does now error, i.e.
import qualified Language.Haskell.TH.Syntax as TH
main :: IO ()
main = putStrLn $(TH.lift =<< TH.runIO (readFile "app/foo.txt"))
fails to compile with message
[1 of 1] Compiling Main ( app/Main.hs, dist/build/stuff/stuff-tmp/Main.o )
---> Starting remote-iserv on port 9094
---| remote-iserv should have started on 9094
0050:err:systray:initialize_systray Could not create tray window
0084:err:setupapi:SetupDefaultQueueCallbackW copy error 1812 L"@C:\\windows\\system32\\drivers\\wineusb.sys,-1" -> L"C:\\windows\\inf\\wineusb.inf"
wine: configuration in L"/build" has been updated.
Listening on port 9094
0024:err:msvcrt:_invalid_parameter (null):0 (null): (null) 0
app/Main.hs:8:17: error:
• Exception when trying to run compile-time code:
app/foo.txt: hGetContents: invalid argument (Bad file descriptor)
Code: TH.lift =<< TH.runIO (readFile "app/foo.txt")
• In the untyped splice:
$(TH.lift =<< TH.runIO (readFile "app/foo.txt"))
|
8 | main = putStrLn $(TH.lift =<< TH.runIO (readFile "app/foo.txt"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
---> killing remote-iserv...
Minimal reproducible example
Repo: https://github.com/amesgen/stuff/tree/haskell.nix-mingwW64-TH-readFile
This fails:
nix build github:amesgen/stuff/haskell.nix-mingwW64-TH-readFile \
--override-input haskellNix github:input-output-hk/haskell.nix/82bc94581865b098985890745c371ef6ce67f1ce
This succeeds:
nix build github:amesgen/stuff/haskell.nix-mingwW64-TH-readFile \
--override-input haskellNix github:input-output-hk/haskell.nix/e00ff6591a2dc86bc021046a213bd5f392a5659f
where
$ git log -2 --oneline 82bc94581865b098985890745c371ef6ce67f1ce
82bc9458 Fix ghc 9 windows cross compilation (#1450)
e00ff659 Update Hackage and Stackage
Metadata
Metadata
Assignees
Labels
No labels