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,244
    • Issues 5,244
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 569
    • Merge requests 569
  • 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
  • #2448
Closed
Open
Issue created Jul 17, 2008 by conal@trac-conal

Type equality constraint not propagated to superclass

The code:

  {-# LANGUAGE TypeFamilies, UndecidableInstances #-}

  -- Demonstrates a bug in propagating type equality constraints

  class VectorSpace v where
    type Scalar v :: *

  class VectorSpace v => InnerSpace v

  instance (VectorSpace u,VectorSpace v, Scalar u ~ Scalar v) => VectorSpace (u,v) where
    type Scalar (u,v) = Scalar u

  instance (InnerSpace u,InnerSpace v, Scalar u ~ Scalar v) => InnerSpace (u,v)

In ghc 6.9.20080622, the last line yields

  Data\TypeEqBug.hs:20:0:
      Couldn't match expected type `Scalar v'
             against inferred type `Scalar u'
      When checking the super-classes of an instance declaration
      In the instance declaration for `InnerSpace (u, v)'

I'd expect the type equality constraint in the InnerSpace instance to get propagated to the parent class.

By the way, without the UndecidableInstances above, we get:

    Constraint is no smaller than the instance head
      in the constraint: Scalar u ~ Scalar v
    (Use -XUndecidableInstances to permit this)
    In the instance declaration for `VectorSpace (u, v)'
Trac metadata
Trac field Value
Version 6.9
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC conal@conal.net
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking