- discount_for b | b `is_elem` cased_args = tyConFamilySize tycon
- | otherwise = 0
- where
- (tycon, _, _) = getAppDataTyConExpandingDicts (idType b)
+
+ discount_for b
+ | is_data && b `is_elem` cased_args = tyConFamilySize tycon
+ | otherwise = 0
+ where
+ (is_data, tycon)
+ = --trace "CoreUnfold.getAppDataTyConExpandingDicts:1" $
+ case (maybeAppDataTyConExpandingDicts (idType b)) of
+ Nothing -> (False, panic "discount")
+ Just (tc,_,_) -> (True, tc)