Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 5.5k
    • Issues 5.5k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 625
    • Merge requests 625
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • 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 CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #1207
Closed
Open
Issue created Mar 07, 2007 by br276@cam.ac.uk@trac-br276

Unnecessary prohibition of unquantified higher-order typeclass constraints

In GHC 6.6, attempting to declare a function (say f) with a type of the form

forall t. ... -> (Num t => ...) -> ...

produces the error:

All of the type variables in the constraint `Num t' are already in scope
    (at least one must be universally quantified here)

This used to make sense -- after all, there's no way f can deduce a Num constraint on t that wasn't provided by its caller, so a higher-order argument with this sort of type is uncallable. But with the addition of GADTs, this is no longer true, since another of f's arguments might, when deconstructed, reveal that t is in fact an Int or a Ratio u. In fact, GADT deconstructors can have types like this. E.g.

data Foo a where
  Bar :: forall a. Num a => a -> Foo a

has a deconstructor of type

forall a r. Foo a -> (Num a => a -> r) -> r

So I think that these types should be allowed, although I haven't found a use for them yet except for writing GADT deconstructors.

On the other hand, one can't write deconstructors for most GADTs even with this change, so perhaps it's the wrong change. If explicit type equality constraints were allowed in Haskell, then I could write

forall t. ... -> (forall t'. (t ~ t', Num t') => ...) -> ...

instead.

Trac metadata
Trac field Value
Version 6.6
Type Bug
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Multiple
Architecture Multiple
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking