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,243
    • Issues 5,243
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 567
    • Merge requests 567
  • 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
  • #20529
Closed
Open
Issue created Oct 19, 2021 by parsonsmatt@trac-parsonsmatt

Instances become invisible across a component boundary

Summary

Reproduction repository: https://github.com/parsonsmatt/visibility

It seems like instances which are considered visible in the library component are no longer considered visible when reifying them in the test component.

The example repo essentially defines:

module C where

    class C a

module A where

    import C

    data A = A
    instance C A

module B where
    import C
    import A

    data B = B A
    instance C B

module T where
    import C
    import B ()

    data T = T
    instance C T

Based on what I've read on visible type class instances, I would expect that import T() would bring into visibility the instances for B and A as well. This is confirmed - in the library, I can write:

module Lib where

import C
import T ()
import Language.Haskell.TH

do
    instances <- reifyInstances ''C [VarP (mkName "a")]
    print instances

and it prints out instance declarations matching A, B, and T.

However, if I run the same code in the test suite for this package, then it only shows the instance C T - it only shows an instance if it was defined in the module that is being imported, not all the transitively imported instances.

Steps to reproduce

Reproduction repository: https://github.com/parsonsmatt/visibility

stack build or cabal build should both work. I've tested with GHC 8.10.3, 8.10.7, and 9.0.1.

Expected behavior

I would expect the instances to be visible just the same in a test-suite or library component.

Environment

  • GHC version used: 8.10.3, 8.10.7, 9.0.1

Optional:

  • Operating System: UBuntu
  • System Architecture: x86
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking