In Mac OS 10.15.7, with haskell platform installed, I am having a weird behavior. The code works fine in ghci but the linking during compilation is not working:
% ghc Merge.hs
Loaded package environment from /Users/ar/.ghc/x86_64-darwin-8.8.4/environments/default
[1 of 1] Compiling Main ( Merge.hs, Merge.o ) [Optimisation flags changed]
Linking Merge ...
ld: can't open output file for writing: Merge, errno=21 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)
But ghci works fine:
% ghci Merge.hs
GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help
Loaded package environment from /Users/ar/.ghc/x86_64-darwin-8.8.4/environments/default
[1 of 1] Compiling Main ( Merge.hs, interpreted )
Ok, one module loaded.
*Main>
Also, % stack runghc -- Merge works but
% stack ghc -- Merge
[1 of 1] Compiling Main ( Merge.hs, Merge.o ) [Data.Aeson changed]
Linking Merge ...
ld: can't open output file for writing: Merge, errno=21 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)
Any idea? I have installed the haskell platform following the instructions in https://www.haskell.org/downloads/ with https://www.haskell.org/platform/mac.html (ghcup).
Code is https://gist.github.com/arademaker/e7ae2e1ef5225807a3e627caa61481da