Aliasing current module qualifier

Andreas Abel abela at chalmers.se
Mon Sep 29 08:57:19 UTC 2014


The other two work arounds are

1. Explicit import lists for the stuff you need.

2. Explicit export list for your module (which you do), and internally 
use non-overloaded identifiers.

     module AnnoyinglyLongModuleName
        ( AnnoyinglyLongModuleName.length
        , AnnoyinglyLongModuleName.null
        ) where

     length = length'
     null   = null'

     length' :: a -> Int
     length' _ = 0

     null' :: a -> Bool
     null' = (== 0) . length'

On 29.09.2014 10:48, Herbert Valerio Riedel wrote:
> On 2014-09-29 at 10:43:28 +0200, Andreas Abel wrote:
>> Indeed, being able to introduce a short name for the current module,
>> or having a fixed short name like 'This' or 'Self' would be neat.
>>
>> The standard workaround for your example would be
>>
>>    import Prelude hiding (length,null)
>
> That won't work though, because what I failed to mention is that I
> needed this (while avoiding CPP) to cope with external modules growing
> their exports lists, such as Data.Foldable starting to export 'length'
> and 'null' in base-4.8.0.0
>
> Moreover, hiding a non-existent symbol is a warning in recent GHC's but
> a hard error in older GHCs, so that's not an option either if you want
> to avoid CPP, support GHCs back to 7.0, and be -Werror-clean.
>
> More generally, 'hiding'-imports aren't robust in terms of
> forward-compatibility.
>
>>
>> Did you try a .hs-boot file with your self-import trick?
>
> Not yet
>

-- 
Andreas Abel  <><      Du bist der geliebte Mensch.

Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden

andreas.abel at gu.se
http://www2.tcs.ifi.lmu.de/~abel/


More information about the ghc-devs mailing list