Skip to content

Monotype check for case branches should not recur through arrows

Consider this module:

{-# LANGUAGE RankNTypes #-}

module Bug where

hr :: (forall a. a -> a) -> ()
hr _ = ()

foo x = case x of () -> hr

bar x = case x of True -> hr
                  False -> hr

On HEAD, foo is accepted while bar is rejected. (This is not a change from previous behavior.) The reason is that GHC requires case branches (when there are more than 1; and when the result of the case is being inferred, not checked) to have monotypes, lest it be left with the task of finding the most general supertype of a bunch of polytypes. However, now that we have simplified subsumption, it is draconian to propagate the monotype check past arrows. I thus claim that bar should be accepted.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information