[GHC] #12680: Permit type equality instances in signatures
GHC
ghc-devs at haskell.org
Mon Oct 10 19:41:06 UTC 2016
#12680: Permit type equality instances in signatures
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner:
Type: feature request | Status: new
Priority: low | Milestone:
Component: Compiler (Type | Version: 8.1
checker) |
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 goldfire):
Replying to [comment:4 ezyang]:
> > type S is much better, because users can't make any assumptions about
a type declaration that they might for a data declaration.
>
> As far as I could tell, GHC actually doesn't make any assumptions when
`data S` denotes an abstract type; so it's just a syntactic wart. It's a
bit bothersome to fix because hs-boot syntax only supports data.
I don't agree. In GHC 8:
{{{
-- A.hs-boot
module A where
data T a
}}}
{{{
-- B.hs
{-# LANGUAGE TypeFamilies #-}
module B where
import {-# SOURCE #-} A
foo :: (T a ~ T b) => a -> b
foo x = x
}}}
These compile fine. GHC must be assuming that `T` is injective. So we must
proceed cautiously.
>
> > It would be super awesome if the user could prove the equality
manually.
>
> Do you have an example of a case where you could do this?
Nope! :)
Hence the level of awesomeness if we could do this. Admittedly well beyond
the scope of Backpack.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12680#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list