Skip to content

Instantly share code, notes, and snippets.

@mukeshtiwari
Created April 13, 2019 04:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mukeshtiwari/0e5e33af98e6194c1c65f2635e0d5413 to your computer and use it in GitHub Desktop.
Save mukeshtiwari/0e5e33af98e6194c1c65f2635e0d5413 to your computer and use it in GitHub Desktop.
{-# OPTIONS_GHC -cpp -fglasgow-exts #-}
{- For Hugs, use the option -F"cpp -P -traditional" -}
module Lib where
import qualified Prelude
unsafeCoerce :: a -> b
#ifdef __GLASGOW_HASKELL__
import qualified GHC.Base
unsafeCoerce = GHC.Base.unsafeCoerce#
#else
-- HUGS
import qualified IOExts
unsafeCoerce = IOExts.unsafeCoerce
#endif
__ :: any
__ = Prelude.error "Logical or arity value used"
When running 'stack build', I am getting this error
keep-learnings-MacBook-Pro:Milad keep_learning$ stack build
Building all executables for `Milad' once. After a successful build of all of them, only specified executables will be rebuilt.
Milad-0.1.0.0: build (lib + exe)
Preprocessing library for Milad-0.1.0.0..
Building library for Milad-0.1.0.0..
/Users/keep_learning/Tmp/Milad/src/Lib.hs:1:16: warning:
-fglasgow-exts is deprecated: Use individual extensions instead
|
1 | {-# OPTIONS_GHC -cpp -fglasgow-exts #-}
| ^^^^^^^^^^^^^^^^^^^^^
[1 of 3] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Lib.o )
/Users/keep_learning/Tmp/Milad/src/Lib.hs:11:1: error: parse error on input ‘import’
|
11 | import qualified GHC.Base
| ^^^^^^
-- While building custom Setup.hs for package Milad-0.1.0.0 using:
/Users/keep_learning/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.4.0.1 build lib:Milad exe:Milad-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
keep-learnings-MacBook-Pro:Milad keep_learning$
I tried removing potential source of bug, but I can't solve it
module Lib where
import qualified Prelude
unsafeCoerce :: a -> b
unsafeCoerce = GHC.Base.unsafeCoerce#
__ :: any
__ = Prelude.error "Logical or arity value used"
Now I am getting
keep-learnings-MacBook-Pro:Milad keep_learning$ stack build
Building all executables for `Milad' once. After a successful build of all of them, only specified executables will be rebuilt.
Milad-0.1.0.0: build (lib + exe)
Preprocessing library for Milad-0.1.0.0..
Building library for Milad-0.1.0.0..
[1 of 3] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Lib.o )
/Users/keep_learning/Tmp/Milad/src/Lib.hs:10:1: error:
parse error (possibly incorrect indentation or mismatched brackets)
|
10 | __ :: any
| ^
-- While building custom Setup.hs for package Milad-0.1.0.0 using:
/Users/keep_learning/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.4.0.1 build lib:Milad exe:Milad-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
keep-learnings-MacBook-Pro:Milad keep_learning$
The Coq version is 8.4pl3
@Lysxia
Copy link

Lysxia commented Apr 13, 2019

module Lib where

import qualified Prelude
import Unsafe.Coerce

__ :: any
__ = Prelude.error "Logical or arity value used"

@Blaisorblade
Copy link

Blaisorblade commented Apr 13, 2019

I think the first error is because imports must come before declarations — fixed in https://gist.github.com/Blaisorblade/a0a22d2de0dc1dd5f77ec395fa05fa9b/61d1ed954b87620d5b37eb958f326317822ab4cc.

The second, instead, appears because you removed -fglasgow-exts and this code needs it. I thought -cpp might not be accepted any more, but it still is.

@Blaisorblade
Copy link

To get rid of the warning, you can try something like
https://gist.github.com/Blaisorblade/a0a22d2de0dc1dd5f77ec395fa05fa9b/2f8ae9f789d61d0e73d9cb947ab602f50c5e40e5

but to replace -fglasgow-exts you might need to add to your LANGUAGE directives all the options in https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#ghc-flag--fglasgow-exts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment