Aliasing current module qualifier

Christian Maeder Christian.Maeder at dfki.de
Mon Sep 29 15:07:05 UTC 2014


Hi,

rather than disambiguating a name from the current module by an 
abbreviated module name, I would prefer a disambiguation as is done for 
local names that shadows existing bindings. Then only imported names 
would need to be qualified (possibly using shorter module names).

So names of the current module would simple shadow unqualified imported 
names.

I think, that would only make previously ambiguous modules compile.

However, this does not help for the case when the whole module plus some 
imported names need to be exported.

   module AnnoyinglyLongModuleName
     ( module AnnoyinglyLongModuleName
     , ...
     ) where

(Without re-exports the whole export list could be omitted)

Cheers Christian

Am 29.09.2014 um 10:19 schrieb Herbert Valerio Riedel:
> Hello *,
>
> Here's a situation I've encountered recently, which mades me wish to be
> able to define a local alias (in order to avoid CPP use). Consider the
> following stupid module:
>
>
>      module AnnoyinglyLongModuleName
>         ( AnnoyinglyLongModuleName.length
>         , AnnoyinglyLongModuleName.null
>         ) where
>
>      length :: a -> Int
>      length _ = 0
>
>      null :: a -> Bool
>      null = (== 0) . AnnoyinglyLongModuleName.length
>
>
> Now it'd be great if I could do the following instead:
>
>      module AnnoyinglyLongModuleName (M.length, M.null) where
>
>      import AnnoyinglyLongModuleName as M -- <- does not work
>
>      length :: a -> Int
>      length _ = 0
>
>      null :: a -> Bool
>      null = (== 0) . M.length
>
> However, if I try to compile this, GHC complains about
>
>      AnnoyinglyLongModuleName.hs:4:1:
>         Bad interface file: AnnoyinglyLongModuleName.hi
>             AnnoyinglyLongModuleName.hi: openBinaryFile: does not exist (No such file or directory)
>
> while GHCi tells me:
>
>      Module imports form a cycle:
>        module ‘AnnoyinglyLongModuleName’ (AnnoyinglyLongModuleName.hs) imports itself
>
>
> Is there some other way (without CPP) to create a local alias for the
> current module-name? If not, is there a reason GHC couldn't support this
> special case of self-aliasing the current module name?
>
>
> PS: Alternatively, this could be done as a language extension but that'd
>      require extending the Haskell grammar:
>
>      module AnnoyinglyLongModuleName as M (M.length, M.null) where
>
>
> Cheers,
>     hvr
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>



More information about the Glasgow-haskell-users mailing list