Re: [GHC] #1401: otherwise ambiguous field names shouldn’t be treated as ambiguous when the data constructor is known

GHC trac at galois.com
Sat Jul 7 14:39:29 EDT 2007


#1401: otherwise ambiguous field names shouldn’t be treated as ambiguous when
the data constructor is known
-------------------------------------------+--------------------------------
    Reporter:  g9ks157k at acme.softbase.org  |        Owner:         
        Type:  feature request             |       Status:  closed 
    Priority:  normal                      |    Milestone:  6.8    
   Component:  Compiler                    |      Version:  6.6.1  
    Severity:  normal                      |   Resolution:  fixed  
    Keywords:                              |   Difficulty:  Unknown
          Os:  Unknown                     |     Testcase:  rn059  
Architecture:  Unknown                     |  
-------------------------------------------+--------------------------------
Changes (by igloo):

  * resolution:  => fixed
  * milestone:  => 6.8
  * testcase:  => rn059
  * status:  new => closed

Old description:

> Consider these three module definitions:
> {{{
> module A where
>     data A = A { label :: Char }
> }}}
> {{{
> module B where
>     data B = B { label :: Char }
> }}}
> {{{
> module X where
>     import A
>     import B
>
>     a = A { label = 'a' }
>
>     b = B { label = 'b' }
>
>     f (A { label = a }) (B { label = b }) = (a,b)
> }}}
> GHC currently treats all the occurences of {{{label}}} in module {{{C}}}
> as ambiguous thereby conforming to the Haskell 98 standard.  However, in
> all these cases there is only one field to which {{{label}}} can refer
> since the data constructor is known.  So it should be possible to let GHC
> treat the above code as legal by using a certain compiler option.  This
> would make the use of Haskell 98 records much more comfortable in
> certain cases.  Fields in different data types could be named equally if
> they denote similar concepts without forcing the user of the data types
> to qualify the field names over and over again.

New description:

 Consider these three module definitions:
 {{{
 module A where
     data A = A { label :: Char }
 }}}
 {{{
 module B where
     data B = B { label :: Char }
 }}}
 {{{
 module X where
     import A
     import B

     a = A { label = 'a' }

     b = B { label = 'b' }

     f (A { label = a }) (B { label = b }) = (a,b)
 }}}
 GHC currently treats all the occurences of {{{label}}} in module {{{C}}}
 as ambiguous thereby conforming to the Haskell 98 standard.  However, in
 all these cases there is only one field to which {{{label}}} can refer
 since the data constructor is known.  So it should be possible to let GHC
 treat the above code as legal by using a certain compiler option.  This
 would make the use of Haskell 98 records much more comfortable in certain
 cases.  Fields in different data types could be named equally if they
 denote similar concepts without forcing the user of the data types to
 qualify the field names over and over again.

Comment:

 Done in the HEAD, with the `-fdisambiguate-record-fields` flag.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1401>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
-------------- next part --------------
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs at haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


More information about the Glasgow-haskell-bugs mailing list