ghci parse error on input

Hello All: Using GHCi, I am working from an existing example which surprisingly contains a parse error in an export statement. I have reproduced the parse error as follows:
module Export ( (^) , (#) ) where import Prelude hiding ((^))
GHCi reports: parse error on input (# I read 5.2 Export Lists in the Haskell Report, but the syntax above does not appear to contradict the Haskell Report. I have eliminated the following solutions: 1. Add (#) to the hiding list. 2. Swap the (#) and (^). 3. Load as non-literate file. Would anyone be able to provide advice on how to avoid this parse error? -- Rick blog: http://phaneron.rickmurphy.org

Hi Rick The code loads fine for me as a .lhs file using ghci / GHC 6.12.1. What is the exact error message and which version of GHC are you using? Best wishes Stephen

On Thu, Mar 18, 2010 at 1:21 PM, Rick Murphy
Using GHCi, I am working from an existing example which surprisingly contains a parse error in an export statement. I have reproduced the parse error as follows:
module Export ( (^) , (#) ) where import Prelude hiding ((^))
GHCi reports: parse error on input (#
I read 5.2 Export Lists in the Haskell Report, but the syntax above does not appear to contradict the Haskell Report.
That's probably due to you using GHCi in a version where the GHC-specific extension concerning # is active by default (with this extension (# 2, 3 #) is an unboxed strict pair). While it's probably possible to compile this code by making sure that the extension isn't active (for instance, using ghc instead of ghci), it is probably a better idea to avoid # as an operator name. -- Jedaï

On 18 March 2010 13:26, Chaddaï Fouché
That's probably due to you using GHCi in a version where the GHC-specific extension concerning # is active by default (with this extension (# 2, 3 #) is an unboxed strict pair). While it's probably possible to compile this code by making sure that the extension isn't active (for instance, using ghc instead of ghci), it is probably a better idea to avoid # as an operator name.
True - if you use -fglasgow-exts rather than adding extensions selectively it bring in the conflicting extension (probably -XMagicHash) If you surround the export and definition of the # function with whitespace it should still work.
module Export ( (^) , ( # ) ) where import Prelude hiding ((^))

Thanks, Stephen. Stephen Tetley wrote:
True - if you use -fglasgow-exts rather than adding extensions selectively it bring in the conflicting extension (probably -XMagicHash)
I believe you are correct. If I remove -fglasgow-exts, GHCI does not report the parse error. I also found the following reference to stolen syntax for -XMagicHash. (Scroll to bottom of page.) http://www.haskell.org/ghc/docs/6.10.1/html/users_guide/syntax-extns.html --- Rick
participants (3)
-
Chaddaï Fouché
-
Rick Murphy
-
Stephen Tetley