Opened 3 years ago

Closed 3 years ago

Last modified 3 years 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 Rev(s): Phab:D359
Wiki Page:


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

    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 3 years ago by simonpj

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

comment:2 Changed 3 years ago by goldfire

Differential Rev(s): Phab:D359

comment:3 Changed 3 years ago by thomie

Status: newpatch

comment:4 Changed 3 years ago by Richard Eisenberg <eir@…>

In f688f0377e13e0762d422ed3a83e74b5d39b5e13/ghc:

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

comment:5 Changed 3 years ago by Richard Eisenberg <eir@…>

In 2cc593dd50197c252d87321280a04f04cc173dbc/ghc:

Bring unbound tyvars into scope during reifyInstances.

Fix #9262.

comment:6 Changed 3 years ago by Richard Eisenberg <eir@…>

In 18a4a5dad3cbee3c8bb4005ec09edf401ebe294c/ghc:

Update release notes for #9262 #8953 #9084.

comment:7 Changed 3 years ago by goldfire

Resolution: fixed
Status: patchclosed

comment:8 Changed 3 years ago by goldfire

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