
Report section 4.2.1 "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."
In that hypothetical context, the field name wouldn't be usable as a function—at least without future Dependent Haskell.
TRex manages to support same label different field type in different records. The record's type includes the field labels, as a distinct Kind. `#lab` is the syntax to access a field labelled `lab`.
#lab :: a\lab => Rec (lab :: b | a) -> b
`(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`. Hugs.Trex> let myTuplePair = (( lab = 5 :: Int, lab2 = True), (lab = 'c', lab3 = Just 7))
in (#lab $ fst myTuplePair, #lab $ snd
myTuplePair)
(5,'c')
On Mon, Sep 20, 2021, 1:19 PM Tom Ellis
* On Mon, Sep 20, 2021 at 01:13:43PM -0400, David Feuer wrote: *>* > Does one field name for one datatype always refer to a field with the *>* same *>* > type? Or is there some wacky extension that would allow things like *>* > *>* > data Foo *>* > = Bar { zoom :: Int } *>* > | Baz { zoom :: Char } *>* > *>* > I'm hoping I don't have to worry about the latter possibility.... *>>* Me too! Under such circumstances what would the type of *>* field-as-function be?*