[Haskell-cafe] beginner's problem about lists
Malcolm.Wallace at cs.york.ac.uk
Wed Oct 11 10:14:23 EDT 2006
Matthias Fischmann <fis at wiwi.hu-berlin.de> wrote:
> > No, your Fin type can also hold infinite values.
> let q = FinCons 3 q in case q of FinCons i _ -> i ==> _|_
> does that contradict, or did i just not understand what you are
That may be the result in ghc, but nhc98 gives the answer 3.
It is not entirely clear which implementation is correct. The Language
Report has little enough to say about strict components of data
structures - a single paragraph in 4.2.1. It defines them in terms of
the strict application operator ($!), thus ultimately in terms of seq,
and as far as I can see, nhc98 is perfectly compliant here.
The definition of seq is
seq _|_ b = _|_
seq a b = b, if a/= _|_
In the circular expression
let q = FinCons 3 q in q
it is clear that the second component of the FinCons constructor is not
_|_ (it has at least a FinCons constructor), and therefore it does not
matter what its full unfolding is.
More information about the Haskell-Cafe