Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: prepend {-# OPTIONS_GHC -w #-} to extracted Haskell files #18962

Open
toku-sa-n opened this issue Apr 21, 2024 · 1 comment
Open
Labels
kind: wish Feature or enhancement requests. part: extraction The extraction mechanism.

Comments

@toku-sa-n
Copy link

toku-sa-n commented Apr 21, 2024

Is your feature request related to a problem?

When I try compiling an extracted Haskell file with -Weverything, GHC complains about many things against the file.

Proposed solution

Prepend {-# OPTIONS_GHC -w #-} to disable all warnings when extracting Haskell files.

Alternative solutions

Fix every warning and error after the extraction. This is very troublesome.

Additional context

Although the use of -Weverything is very extreme, I believe disabling all warnings and errors is reasonable. One example is that Cabal, an official Haskell build tool, generates Paths_*.hs with the pragma.

@toku-sa-n toku-sa-n added kind: wish Feature or enhancement requests. needs: triage The validity of this issue needs to be checked, or the issue itself updated. labels Apr 21, 2024
@JasonGross
Copy link
Member

JasonGross commented Apr 21, 2024

There is Set Extraction File Comment, but it does not work for this purpose.

From Coq Require Import Extraction.

Extraction Language Haskell.
Set Extraction File Comment "{-# OPTIONS_GHC -w #-}".
Recursive Extraction id.

gives

{-# OPTIONS_GHC -cpp -XMagicHash #-}
{- For Hugs, use the option -F"cpp -P -traditional" -}

{- {-# OPTIONS_GHC -w #-} -}

module Main where

import qualified Prelude

#ifdef __GLASGOW_HASKELL__
import qualified GHC.Base
#if __GLASGOW_HASKELL__ >= 900
import qualified GHC.Exts
#endif
#else
-- HUGS
import qualified IOExts
#endif

#ifdef __GLASGOW_HASKELL__
type Any = GHC.Base.Any
#else
-- HUGS
type Any = ()
#endif

id :: Any -> Any
id x =
  x

I propose that if the extraction file comment begins with {-#, then the magic header should be disabled in Haskell.

@JasonGross JasonGross added part: extraction The extraction mechanism. and removed needs: triage The validity of this issue needs to be checked, or the issue itself updated. labels Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: wish Feature or enhancement requests. part: extraction The extraction mechanism.
Projects
None yet
Development

No branches or pull requests

2 participants