[GHC] #15432: Referring to current module (or aliasing current module)
GHC
ghc-devs at haskell.org
Mon Jul 23 13:44:05 UTC 2018
#15432: Referring to current module (or aliasing current module)
-------------------------------------+-------------------------------------
Reporter: moll | Owner: (none)
Type: feature | Status: new
request |
Priority: normal | Milestone: ⊥
Component: Compiler | Version: 8.2.2
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Hey,
Suppose I got a record type `Game` in a module `Lib.Game` that has a field
`player`. I'd occasionally like to use the variable `player` in a closure,
but still refer to the `player` field accessor once to assign the
variable. Is it me or right now there's no way to refer to the current
module by anything other than its full name? That is, to disambiguate the
variable and function, I have to type `let player = Lib.Game.player`.
In other words, I'd like the invocation of `Lib.Game.player` below to be
shortened somehow, either by assigning an alias to the current module via
`import qualified` (can't now as it results in a self-cycle) or by some
other means of referring to the closing module.
{{{#!hs
module Lib.Game where
data Game = Game {player :: Player}
play game = foo player where player = Lib.Game.player game
}}}
This is vaguely similar to https://ghc.haskell.org/trac/ghc/ticket/10336,
but the `SOURCE` pragma seems to be about actually cyclical imports.
Thanks!
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15432>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list