Am Montag, den 07.11.2011, 21:41 +0000 schrieb Barney Hilken: > > The problem with this approach is that different labels do not have > > different representations at the value level. > > I think this is an advantage, because it means you don't have to carry > this stuff about at runtime. > > > This allows me to pattern match records, since I can construct record > > patterns that contain fixed labels: > > > > X :& MyName1 := myValue1 :& MyName2 := myValue2 > > > > I cannot see how this could be done using kind String. Do you see a > > solution for this? > > > > A similar problem arises when you want to define a selector function. > > You could implement a function get that receives a record and a label as > > arguments. However, you could not say something like the following then: > > > > get myRecord MyName1 > > > > Instead, you would have to write something like this: > > > > get myRecord (Label :: MyName1) > > Just define a constant > > myName1 = Label :: MyName1 > > for each label you actually use, and you can use it in both get and > pattern matching
You cannot use such a constant in a pattern. You need a data constructor if you want to use pattern matching. Best wishes, Wolfgang _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users