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,866
    • Issues 4,866
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 461
    • Merge requests 461
  • 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
  • #3155
Closed
Open
Created Apr 07, 2009 by MartijnVanSteenbergen@trac-MartijnVanSteenbergen

TypeOperators/Rank2Types clash

Consider the following piece of code:

{-# LANGUAGE GADTs #-}

data Any s where
  Any :: s ix -> ix -> Any s

data AnyR s r where
  AnyR :: s ix -> r ix -> AnyR s r

unR :: (forall ix. r ix -> ix) -> AnyR s r -> Any s
unR f (AnyR ix rix) = Any ix (f rix)

GHC reports:

    Illegal operator `.' in type `forall ix . (r ix -> ix)'
      Perhaps you intended to use -XRankNTypes or similar flag
      to enable explicit-forall syntax: forall <tvs>. <type>

Enabling TypeOperators causes the error to change to:

    Occurs check: cannot construct the infinite type: ix = r ix
    In the pattern: AnyR ix rix
    In the definition of `unR': unR f (AnyR ix rix) = Any ix (f rix)

Which is very confusing, as the solution (still) is to turn on Rank2Types.

Could it be made so that the error message stays the same when TypeOperators is turned on?

Trac metadata
Trac field Value
Version 6.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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