Opened 11 months ago

Closed 7 months ago

Last modified 7 months ago

#9262 closed feature request (fixed)

Allow free variables in reifyInstances

Reported by: goldfire Owned by: goldfire
Priority: normal Milestone:
Component: Template Haskell Version: 7.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: th/T9262
Blocked By: Blocking:
Related Tickets: Differential Revisions: Phab:D359

Description

When I say

{-# LANGUAGE TemplateHaskell #-}

module Bug where

import Language.Haskell.TH

$( do insts <- reifyInstances ''Eq [ListT `AppT` VarT (mkName "a")]
      runIO $ putStrLn $ pprint insts
      return [] )

I get

Bug.hs:7:4:
    Not in scope: type variable ‘a’
    In the argument of reifyInstances: GHC.Classes.Eq [a]

But, I wanted the declaration for instance Eq a => Eq [a]. The error message isn't wrong, exactly -- a really isn't in scope -- but I think we can do better by just treating variables as fresh.

Change History (8)

comment:1 Changed 10 months ago by simonpj

That makes sense to me -- another fairly easy TH improvement waiting for a willing volunteer.

comment:2 Changed 7 months ago by goldfire

  • Differential Revisions set to Phab:D359

comment:3 Changed 7 months ago by thomie

  • Status changed from new to patch

comment:4 Changed 7 months ago by Richard Eisenberg <eir@…>

In f688f0377e13e0762d422ed3a83e74b5d39b5e13/ghc:

Test #9262 in th/T9262, and update other tests.

comment:5 Changed 7 months ago by Richard Eisenberg <eir@…>

In 2cc593dd50197c252d87321280a04f04cc173dbc/ghc:

Bring unbound tyvars into scope during reifyInstances.

Fix #9262.

comment:6 Changed 7 months ago by Richard Eisenberg <eir@…>

In 18a4a5dad3cbee3c8bb4005ec09edf401ebe294c/ghc:

Update release notes for #9262 #8953 #9084.

comment:7 Changed 7 months ago by goldfire

  • Resolution set to fixed
  • Status changed from patch to closed

comment:8 Changed 7 months ago by goldfire

  • Test Case set to th/T9262
Note: See TracTickets for help on using tickets.