Haskell/Alex: Warning: Tab character
Asked Answered
P

1

6

I'm writing a toy language in haskell. I'm using Alex to generate a scanner. Every time I build my project with cabal, I get the following warnings:

dist/build/optimiser/optimiser-tmp/Lexer.hs:465:1: Warning:
    Tab character

dist/build/optimiser/optimiser-tmp/Lexer.hs:466:1: Warning:
    Tab character

dist/build/optimiser/optimiser-tmp/Lexer.hs:467:1: Warning:
    Tab character

dist/build/optimiser/optimiser-tmp/Lexer.hs:471:1: Warning:
    Tab character

dist/build/optimiser/optimiser-tmp/Lexer.hs:472:1: Warning:
    Tab character

(plus about 10 more of these warnings)

It seems that the alex-generated scanner uses tabs instead of spaces, and ghc's default behaviour is to warn the user about this.

Is anyone aware of a way to either force alex to use spaces, or to suppress those warnings from ghc (via cabal)?

Protestantism answered 14/5, 2015 at 11:49 Comment(2)
This warning is caused by a bug in Alex, which appears to have been fixed by Simon Marlow two weeks ago. See github.com/simonmar/alex/issues/61. Try to get the latest version of Alex.Sass
@Jubobs good to know, thanks for the heads-up. The update doesn't seem to have reached Hackage or my disribution's repos yet, but I can tolerate the issue until then.Protestantism
E
10

As mentioned in the comments, this is supposedly fixed in alex master. Until you can use the fixed version, you can try adding

ghc-options: -fno-warn-tabs

to your .cabal file.

Edwinaedwine answered 14/5, 2015 at 14:51 Comment(5)
Is it possible to make that flag apply only to the modules Alex generates? It looks like a heavy hammer.Rinker
In fact ... I am not convinced this was fixed. The commit you point to only removes tabs from the Alex source code, not from the code it generates.Rinker
That'll do nicely for the time being. Cheers.Protestantism
@Rinker Can't you manually ass {-# GHC_OPTIONS #-} to the top of the Alex input files?Fantasy
@Fantasy That should be OPTIONS_GHC. So to be clear: {-# OPTIONS_GHC -fno-warn-tabs #-} should be at the top of the .x.Traceytrachea

© 2022 - 2024 — McMap. All rights reserved.