Skip to content

Regression with PartialTypeSignatures in 8.10

This is a regression in 8.10, the code was fine in 8.8.2.

-- Bug.hs
{-# LANGUAGE RankNTypes                #-}
{-# LANGUAGE PartialTypeSignatures     #-}
module Bug where

import Control.Exception

data WrappedException = WrappedException
  deriving (Show)

fromSomeException :: SomeException -> WrappedException
fromSomeException _ = WrappedException

instance Exception WrappedException

fun :: IO () -> (forall e. (Exception e) => e -> IO ()) -> _ -- If I say IO () here it works
fun someComputation reportException = 
  try someComputation >>= \x -> case x of
    Left someException -> reportException (fromSomeException someException) -- or if I turn on TypeApplications and put @_ as the first argument here
    Right _ -> pure ()

Problem:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.1

$ ghc Bug.hs  -fforce-recomp
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:18:27: error:
    • Couldn't match kind ‘Constraint’ with ‘*’
      When matching types
        WrappedException :: *
        Exception e0 :: Constraint
      Expected type: WrappedException -> e0 -> IO ()
        Actual type: Exception e0 => e0 -> IO ()
    • The function ‘reportException’ is applied to one argument,
      but its type ‘Exception e0 => e0 -> IO ()’ has none
      In the expression:
        reportException (fromSomeException someException)
      In a case alternative:
          Left someException
            -> reportException (fromSomeException someException)
   |
18 |     Left someException -> reportException (fromSomeException someException)
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Edited by Ryan Scott
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information