[GHC] #15379: Don't reject user-written instances of KnownNat and friends in hsig files
GHC
ghc-devs at haskell.org
Tue Jul 17 12:15:41 UTC 2018
#15379: Don't reject user-written instances of KnownNat and friends in hsig files
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.3
Resolution: | Keywords: backpack
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
I'm not sure I'm following all the details here, but can you take
inspiration from the way that instances in `hs-boot` files work? If you
have
{{{
Foo.hs-boot
data T
instance Eq T
}}}
then in the `hi-boot` file (which we get from compiling `Foo.hs-boot`) we
will have something like
{{{
$d77 : Eq T
}}}
That is, the arbtrarily named `$d77` is a witness for `Eq T`. Modules
importing `Foo.hi-boot` use `$d77` when they need `Eq T`.
Then when compiling `Foo.hs` we generate the real instance
{{{
$d98 = <the code for equality on T> :: Eq T
}}}
and (having read the `Foo.hi-boot` file, we also generate a compatibility
stub
{{{
$d77= $d98
}}}
so that references to `$d77` will end up in `$d98`.
Maybe the same approach will work for `hsig` files. Edward will know.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15379#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list