[Haskell] Unnamed fields

Ian Lynagh igloo at earth.li
Tue Nov 16 10:04:02 EST 2004


Hi all,

Is there a good reason why I can't say

    data Bar = Bar { _ :: Int, _ :: Char, x :: Bool }

?
(Or "data Bar = Bar { Int, Char, x :: Bool }" if you prefer, but that's
susceptible to typos of the "x, y, z :: Int" syntax causing confusion).

I have a large datastructure in which there is one field I wish to be
able to use field reads and updates for, but I don't want to have to
invent loads of names for the other fields. The only minor issue I can
think of is that the derived Show instance would say

    Bar{_=5,_='c',x=True}

but, while it's a bit odd, I don't think it's a problem.


Thanks
Ian



More information about the Haskell mailing list