<div dir="ltr"><font face="arial, sans-serif">Report section 4.2.1</font><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">"A `data` declaration may use the same field label in multiple constructors as long as the typing of the field is the same in all cases after type synonym expansion."</font></div><div><div><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="arial, sans-serif">> In that hypothetical context, the field name wouldn't be usable as a
> function—at least without future Dependent Haskell.</font></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="arial, sans-serif">TRex manages to support same label different field type in different records.</font></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="arial, sans-serif">The record's type includes the field labels, as a distinct Kind. `#lab` is the syntax to access a field labelled `lab`.</font></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="arial, sans-serif">>    #lab :: a\lab => Rec (lab :: b | a) -> b<br></font></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="arial, sans-serif">`(lab :: b | a)` is of Kind Row, means a row with label `lab` at type `b`; `| a` captures any other fields in the record; `Rec( )` is a magic type constructor that makes Rows into Kind `*`. Context `a\lab` means `a` must not include label `lab`.</font></pre><font face="arial, sans-serif">Hugs.Trex> let myTuplePair = (( lab = 5 :: Int, lab2 = True), (lab = 'c', lab3 = Just 7))</font></div><div><font face="arial, sans-serif">>                                    in (#lab $ fst myTuplePair, #lab $ snd myTuplePair)<br></font><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="arial, sans-serif">>    (5,'c')<br></font></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="arial, sans-serif">
</font>
On Mon, Sep 20, 2021, 1:19 PM Tom Ellis <
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk</a>> wrote:

><i> On Mon, Sep 20, 2021 at 01:13:43PM -0400, David Feuer wrote:
</i>><i> > Does one field name for one datatype always refer to a field with the
</i>><i> same
</i>><i> > type? Or is there some wacky extension that would allow things like
</i>><i> >
</i>><i> > data Foo
</i>><i> >   = Bar { zoom :: Int }
</i>><i> >   | Baz { zoom :: Char }
</i>><i> >
</i>><i> > I'm hoping I don't have to worry about the latter possibility....
</i>><i>
</i>><i> Me too!  Under such circumstances what would the type of
</i>><i> field-as-function be?</i></pre></div></div></div>