3

I want to sort my imports by name, qualified and unqualified

import           A
import qualified B
import           C
import qualified D

But there are big gaps in code, and lines are long, so I want to shorten it

{-# LANGUAGE CPP #-}
#define importq import qualified

import  A
importq B
import  C
importq D

It looks great, but now I get error from CPP

error: invalid preprocessing directive #!
#!/usr/bin/env runhaskell
^
phase `C pre-processor' failed (exitcode = 1)

if I want to run my program with help of shebang. CPP confilcts with shebangs.

How to deal with this problem? Is there another simple macro system allowing to make an alias importq = import qualified? Or is there another way to shorten import qualified?

Yuri Syro
  • 549
  • 2
  • 16
  • 19
    no... just get used to it, that's the language. – luqui Jun 08 '14 at 08:39
  • 9
    The problem here is not just the shortening of `import qualified`, but the fact that `runhaskell` scripts seem to be incompatible with CPP because of the shebang. This looks as a bug of `runhaskell`, IMO, which should remove the shebang before calling CPP. – chi Jun 08 '14 at 10:29

0 Answers0