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

  • SEARCH
  • Home
  • 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 8161609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:32:07+00:00 2026-06-06T18:32:07+00:00

Suppose you have a module that you know is safe. You want to mark

  • 0

Suppose you have a module that you know is safe.

You want to mark it as Safe Haskell with something like {-# LANGUAGE Safe #-} in the module itself or with something like Extensions: Safe in the cabal file. Unfortunately, doing either of these breaks backwards compatibility (i.e. the module will not build on GHC < 7.2).

If the entire library is Safe, you can just wrap the extensions directive in the cabal file like this:

if impl(ghc >= 7.2)
  Extensions: Safe

But that only works for the entire library.

How do you mark a single module as Safe Haskell in a backwards compatible way?

  • 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-06-06T18:32:08+00:00Added an answer on June 6, 2026 at 6:32 pm

    If you don’t need to support GHC versions older than 6.12 (6.12.3 is the oldest I have tested the construct with¹), you can do it with the preprocessor,

    {-# LANGUAGE CPP #-}
    #if __GLASGOW_HASKELL__ >= 702
    {-# LANGUAGE Safe #-}
    #endif
    

    Alternatively, you can use a flag in the .cabal file to select the source file which to include.

    ¹ For ghc-6.12, you must have all {-# LANGUAGE #-} pragmas not guarded by the #if in one group before the #if, since 7.0, they may also appear after the #if.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a DLL that exports some functions and I know an address
Suppose I have a pure virtual method in the base interface that returns to
Suppose I have a static method of my class that returns an object of
Suppose we have the name written in any none-latin letters - languages, like Arabic,
Suppose I have a class Baz that inherits from classes Foo and Bar ,
Suppose I have a process that is updating a record and encounters a record
I have a module that uses std::string as part of its interface. I would
Suppose I have a data type like data D a = D a a
Possible Duplicate: Retrieving python module path Suppose I have code in 3 python files.
Let's suppose I have the following code: TEModule teModule = Context.TEModules.Where(module => module.EnumValue.Equals(text.ModuleName)).FirstOrDefault(); if

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.