[GHC] #12159: Record-like GADTs with repeated fields (of same type) rejected

GHC ghc-devs at haskell.org
Fri Jun 10 16:03:25 UTC 2016


#12159: Record-like GADTs with repeated fields (of same type) rejected
-------------------------------------+-------------------------------------
        Reporter:  heisenbug         |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by adamgundry):

 Yes, it's not quite anti-unification, but something like "find the most
 general type that binds all the type variables used in the field type, and
 can be instantiated to all the result types".

 I think we can reasonably require all the fields to have syntactically the
 same type, and use that as the result type of the selector. So we would
 pick `T a -> Bool` over `T a -> a`. Moreover, this wouldn't allow the
 following:

 {{{#!hs
 data S :: * -> * where
    S1 :: { s :: a    } -> S a
    S2 :: { s :: Bool } -> S Bool
    S2 :: { s :: Int  } -> S Int
 }}}

 even though in principle it could have a selector of type `S a -> a`.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12159#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list