Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,931
    • Issues 4,931
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 464
    • Merge requests 464
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #13594
Closed
Open
Created Apr 20, 2017 by Ryan Scott@RyanGlScottMaintainer

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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking