Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,394
    • Issues 4,394
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 377
    • Merge Requests 377
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #3670

Closed
Open
Opened Nov 16, 2009 by rl@cse.unsw.edu.au@trac-rl

Allow RULES for higher-ranked terms

Here is a small code sample:

foo :: (forall m. m a -> m b) -> m a -> m b
foo f = f

bar :: (forall m. m a -> m a) -> m a -> m a
bar f = f

I'd like to specialise foo to bar whenever possible but there seems to be no way of doing so. This doesn't work:

{-# RULES "foo/bar" foo = bar #-}

GHC complains:

    Cannot match a monotype with `(forall (m1 :: * -> *). m1 a -> m1 b)
                                  -> m a
                                  -> m b'

Adding a signature to the rhs of the rule doesn't help. GHC doesn't accept signatures in the lhs. The following works, of course, but it's not as general:

{-# RULES "foo/bar" forall (f :: (forall m. m a -> m a)). foo f = bar f #-}
Trac metadata
Trac field Value
Version 6.13
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#3670