empty field label constructor infelicity
Hal Daume III
hdaume@ISI.EDU
Tue, 24 Sep 2002 16:01:58 -0700 (PDT)
Hi again,
The report says "The expression F {}, where F is a data constructor, is
legal whether or not F was declared with record syntax, provided F has no
strict fields: it denotes F _|_1 ... _|_n where n is the arity of F."
It unclear to me why there needs to be this provision for records with
strict fields -- just let them be undefined -- but that notwithstanding,
GHC seems to do the wrong thing:
> module Foo where
> data F = F !Int deriving (Show, Eq)
> data G = G Int deriving (Show, Eq)
If we then load it up in ghci, both "F {}" and "G {}" ellicit the same
error: "Missing field in record construction".
If we do:
Foo> case (F {}) of { F x -> "1" }
we get the exeption. If we use G instead of F, we correctly get "1".
Hugs seems to obey the report. For "F {}" it
give: "INTERNAL_ERROR: depConFlds" which is different from "G {}" which
yields "G" followed by "Program error: {undefined}".
For the case expressions, Hugs generates "INTERNAL ERROR: depConFlds" for
F and "1" for G.
Arguably, this is weirdness in the report, but I think it's clear that GHC
isn't doing the right thing (where right thing is defined to be what the
report says).
- Hal
--
Hal Daume III
"Computer science is no more about computers | hdaume@isi.edu
than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume