'lub' and 'both' on strictness - what does it mean for products to have different arity?
Ömer Sinan Ağacan
omeragacan at gmail.com
Fri Feb 19 17:27:29 UTC 2016
I was looking at implementations of LUB and AND on demand signatures and I
found this interesting case:
lubStr (SProd s1) (SProd s2)
| length s1 == length s2 = mkSProd (zipWith lubArgStr s1 s2)
| otherwise = HeadStr
The "otherwise" case is interesting, I'd expect that to be an error. I'm trying
to come up with an example, let's say I have a case expression:
case x of
P1 -> RHS1
P2 -> RHS2
and y is used in RHS1 with S(SS) and in RHS2 with S(SSS). This seems to me like
a type error leaked into the demand analysis.
Same thing applies to `bothDmd` too. Funnily, it has this extra comment on this
bothStr (SProd s1) (SProd s2)
| length s1 == length s2 = mkSProd (zipWith bothArgStr s1 s2)
| otherwise = HyperStr -- Weird
Does "Weird" here means "type error and/or bug" ?
Should I try replacing these cases with panics and try to validate?
More information about the ghc-devs