Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6585293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:38:40+00:00 2026-05-25T16:38:40+00:00

I have to build some app that depends on OS. For example I’m searching

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:38:40+00:00Added an answer on May 25, 2026 at 4:38 pm

    This can be solved using the CPP preprocessor.

    In your .cabal file, add

    if os(windows)
      Cpp-options: -DWINDOWS
    else
      Build-depends: unix
    

    Then add a module which will conditionally export isSymbolicLink from the unix package, or a dummy one for Windows.

    {-# LANGUAGE CPP #-}
    module Compatibility (isSymbolicLink) where
    
    #ifndef WINDOWS
    import System.Posix.Files
    #else
    isSymbolicLink _ = return False
    #endif
    

    Now just import this module whereever you need to use this function, and you should be good to go.


    Another option is to stick with your initial approach, but move your System/Posix/Files.hs into a subdirectory which you conditionally add to Hs-Source-Dirs.

    if os(windows)
      Other-modules: System.Posix.Files
      -- Assuming you moved it to windows/System/Posix/Files.hs
      Hs-source-dirs: .,windows    
    else
      Build-depends: unix
      Hs-Source-Dirs: .
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to build an App that need authentication over a DB (online). When
I have a post-build event that runs some commands for a c# project. The
I have some tables that I build as a part of my report rollup.
I have an app that has some non-US Localizable.strings files. They appear in the
We have a client who wants to build an app that essentially functions as
I have a Flex App that allows you to dynamically build an animation. It
I have some app ideas that I want to release for free (with ads).
I want to build an app that can communicate to some external third party
I have a grails app that has some run-scripts that I want to run
I have a simple app that downloads some data from a webservice and displays

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.