I have to build some app that depends on OS. For example I'm searching over directory, and if I see some item is symbolic link (in linux), I just skip them and go over. To check this I use function System.Posix.Files.isSymbolicLink that ships by "unix" package. The problem is that this package would not build on Windows, and I have to bypass this limitation somehow when app builds on Windows. I've tried this trick:
1) Created additional file: ./System/Posix/Files.hs, where exposed function isSymbolicLink which always returns False.
2) Updated .cabal file with following:
if os(windows)
other-modules: System.Posix.Files
else
build-depends: unix
But, despite my configuration, cabal build always builds my /System/Posix/Files.hs since I have import System.Posix.Files in my main.hs:
Preprocessing executables for test-1.1.1...
Building test-1.1.1...
[1 of 2] Compiling System.Posix.Files ( System/Posix/Files.hs, dist/build/test/test-tmp/System/Posix/Files.o )
[2 of 2] Compiling Main ( main.hs, dist/build/test/test-tmp/Main.o )
Linking dist/build/test/test ...
So even I build on linux, application gets my blank isSymbolicLink function instead those provided by "unix" package. How can I tell to cabal do not include this file, and use module provided by "unix" package when I build on linux? Or maybe there is some another approach to solve such problems?