Typechecker behavior w.r.t. BangPatterns and nested foralls has changed in 8.2
Try running this code in GHCi:
λ> :set -XBangPatterns -XRankNTypes -XTypeFamilies
λ> let x :: forall a . a ~ Integer => forall b. b ~ Integer => (a, b); !x = (1, 2)
In GHC 8.0.1 and 8.0.2, this works. But in GHC 8.2.1:
<interactive>:3:74:
Couldn't match expected type ‘forall a.
(a ~ Integer) =>
forall b. (b ~ Integer) => (a, b)’
with actual type ‘(Integer, Integer)’
In the expression: (1, 2)
In a pattern binding: !x = (1, 2)
If you put this code into a source file:
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
module Bug where
x :: forall a . a ~ Integer => forall b. b ~ Integer => (a, b)
!x = (1, 2)
Then it also works in GHC 8.0.1. and 8.0.2, but it errors on GHC 8.2 (this time with a different error):
GHCi, version 8.2.0.20170413: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:6:1: error:
Overloaded signature conflicts with monomorphism restriction
x :: forall a. a ~ Integer => forall b. b ~ Integer => (a, b)
|
6 | x :: forall a . a ~ Integer => forall b. b ~ Integer => (a, b)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1-rc2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |