[GHC] #15470: Record projections with ambiguous types
GHC
ghc-devs at haskell.org
Wed Sep 5 14:05:51 UTC 2018
#15470: Record projections with ambiguous types
-------------------------------------+-------------------------------------
Reporter: sweirich | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: 8.8.1
Component: Compiler | Version: 8.4.3
Resolution: | Keywords:
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 thought that visible type applications would work too, so I tried it
(diff below).
Alas it turns out that we give record selectors ''nested'' forall types.
For example from
{{{
data T m = MkT { fld :: forall a. m a -> m a }
}}}
we get the selector:
{{{
fld :: forall m. T m -> (forall a. m a -> m a)
}}}
So we can't use scoped type variables from the signature to instantiate in
the RHS, ike this
{{{
fld :: forall m. T m -> (forall a. m a -> m a)
fld (MkT x) = x @ a -- No
}}}
Bother.
Maybe we can change this assumption, and put all the foralls (and
constraints) at the top of record selectors? I'm not sure of the
consequences of doing so. The choice is made in the definition of
`sel_ty` in `TcTyDecls.mkOneRecordSelector`.
It affects user code. For example, do we write `fld @IO r @Int` or `fld
@IO @Int r`? So it's be a breaking change.
I'm not sure I see any other solution, alas.
Richard, Mr VTA?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15470#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list