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
  • #1835
Closed
Open
Issue created Nov 06, 2007 by guest@trac-guest

Provide information of the instance environment

This feature request was brought up in [1].

Right now TH doesn't have access to the instance environment of the typechecker. Thus, it's impossible to check whether a class instance exists for certain type, making impossible to guarantee the generation of correct code in some cases.

For example, that happens when, for a justified reason, the function to be spliced takes a variable Name as argument and not a value. There is no way to force a class constraint on names nor a way to check whether the variable type (obtained with reify) is an instance of a certain class. If the generated code makes use of any class function, its possible to generate incorrect code.

I suggest adding a function similar to this one:

isClassInstance :: Name   -- ^ Class name
                -> Type   -- ^ Type to check
                -> Q Bool

Another option would be extending ClassI to provide the list of instances of a class and code 'isClassInstance' using that information.

[1] http://www.haskell.org/pipermail/template-haskell/2007-November/000645.html

Trac metadata
Trac field Value
Version 6.8.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC alfonso.acosta@gmail.com
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