Skip to content

PartialTypeSignatures regression in 9.8

Summary

There seems to be a regression in -XPartialTypeSignatures, with GHC asking me to add a constraint to the context of an inferred type, where as previously this constraint would have been inferred as well.

Steps to reproduce

This compiles and runs fine in 9.6.3:

{-# LANGUAGE PartialTypeSignatures #-}
module Main where

checkFunc :: _ -> Bool
checkFunc f = f == 3

main :: IO ()
main = print (checkFunc 3)
$ ghc test.hs && ./test
[1 of 2] Compiling Main             ( test.hs, test.o ) [Source file changed]

test.hs:4:14: warning: [GHC-88464] [-Wpartial-type-signatures]
    • Found type wildcard ‘_’ standing for ‘Integer’
    • In the type signature: checkFunc :: _ -> Bool
  |
4 | checkFunc :: _ -> Bool
  |              ^
[2 of 2] Linking test [Objects changed]
$ ./test
True

but when compiled with 9.8.1:

$ ghc test.hs && ./test
[1 of 2] Compiling Main             ( test.hs, test.o )

test.hs:5:17: error: [GHC-39999]
    • No instance for ‘Eq a’ arising from a use of ‘==’
      Possible fix:
        add (Eq a) to the context of
          the inferred type of checkFunc :: a -> Bool
    • In the expression: f == 3
      In an equation for ‘checkFunc’: checkFunc f = f == 3
  |
5 | checkFunc f = f == 3
  |                 ^^

test.hs:5:20: error: [GHC-39999]
    • No instance for ‘Num a’ arising from the literal ‘3’
      Possible fix:
        add (Num a) to the context of
          the inferred type of checkFunc :: a -> Bool
    • In the second argument of ‘(==)’, namely ‘3’
      In the expression: f == 3
      In an equation for ‘checkFunc’: checkFunc f = f == 3
  |
5 | checkFunc f = f == 3
  |

Expected behavior

I would expect it to compile as it did in 9.6.

Environment

  • GHC version used: 9.6.3, 9.8.1

Optional:

  • Operating System: Ubuntu 22.04
  • System Architecture: WSL2
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information