Skip to content
GitLab
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 5,258
    • Issues 5,258
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 563
    • Merge requests 563
  • 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 CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #11793
Closed
Open
Issue created Apr 05, 2016 by Eric Seidel@gridaphobeReporter

Confusing type error from constrained class method

import GHC.Stack

class Foo a where
  foo :: HasCallStack => a -> String

instance Foo () where
  foo () = prettyCallStack callStack

main = putStrLn (foo ())
~/S/ghc> ./inplace/bin/ghc-stage2 --make Foo.hs 
[1 of 1] Compiling Main             ( Foo.hs, Foo.o )

Foo.hs:4:3: error:
    • Constraint ‘HasCallStack’ in the type of ‘foo’
        constrains only the class type variables
      Use ConstrainedClassMethods to allow it
    • When checking the class method:
        foo :: forall a. (Foo a, HasCallStack) => a -> String
      In the class declaration for ‘Foo’

The error says that HasCallStack constrains the class type variable a, which is incorrect. Is the error message supposed to be that HasCallStack should constrain the class type variable and nothing else?

Trac metadata
Trac field Value
Version 8.0.1-rc2
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