isRecursiveTyCon
José Manuel Calderón Trilla
jmct at jmct.cc
Fri Mar 4 02:46:04 UTC 2016
Hello,
I'm extending GHC's demand analysis to sum types, but _not_ recursive
types. I was searching for a function that would tell me if a TyCon is
recursive, so that I could analyse Maybes but avoid Lists.
I found isRecursiveTyCon, but it's not actually for this purpose,
there's actually a long note in typecheck/TcTyDecls.hs that explains
why it's not fit for determining which type constructors are recursive
in general. The key point from the note is
"The "recursive" flag for algebraic data types is irrelevant (never
consulted) for types with more than one constructor."
It seems that because the strictness analyser never worked over sum
types it never had to worry about recursive sum types and at some
point the flag that says a data type is recursive broke for sum types
without anyone knowing.
For example the following mutually recursive data types have different
return values from isRecursiveTyCon
data OddNat = One | SuccO EvenNat
data EvenNat = Zero | SuccE OddNat
Does anyone know of the simplest way to test for this?
Thanks for your time,
Jose
More information about the ghc-devs
mailing list