[Haskell-beginners] Named fields in data types
legajid
legajid at free.fr
Tue Nov 17 16:24:26 EST 2009
Hello,
i've some trouble with named fields in data types.
data Carnet = Adresse { nom :: String, cp :: Integer, ville :: String }
|
Telephone {nom::String, telnum::String}
deriving Show
contact01 = Adresse "Didier" 51100 "Reims"
contact02 = Adresse {nom="Laure", cp=0} -- line 1
--contact02 Adresse { ville="Nogent" } -- line 2
--contact02 { ville="Nogent" } -- line 3
contact03=Telephone "Didier" "0326..." -- line 4
When loading this source :
line 1 says "warning : Fields not initialized :ville
line 2 and 3 when uncommented give parse error (possibly indentation)
I'm ok with line 1.
Is it possible to write such things as line2 or 3 ? Which syntax ?
Thanks for help.
Didier.
More information about the Beginners
mailing list