[Haskell-cafe] case switch covering all possible constructor but still fails
nathan.huesken at posteo.de
Sat Apr 13 11:42:48 CEST 2013
I am trying to fix (or at least get my head around) this:
encounter this problem which makes me think I am not understanding
something fundamental here (and I believe this not to be haste specific)...
OK, the problem is that this code:
genAlt :: Bool -> JSVar -> JSVar -> StgAlt -> JSGen Config JSAlt
genAlt tailpos scrut res (con, args, used, body) = do
construct <- case con of
DEFAULT -> return Def
LitAlt l -> Cond <$> genLit l
DataAlt c | Right tag <- genDataConTag c -> return $ Cond tag
_ -> error "Bad data constructor tag generated!"
Looking at StgAlt, I conclude that con must be of type AltCon, which is
defined like this (from CoreSyn.lhs of the ghc source):
= DataAlt DataCon
| LitAlt Literal
deriving (Eq, Ord, Data, Typeable)
What I do not understand: The case switch covers all possibilities of
AltCon. So how can this happen?
Using trace, the con seemed to have the type "GHC.Integer.Type.S#" in
the case of the erro.
More information about the Haskell-Cafe