Opened 6 years ago

Last modified 3 years ago

#8460 infoneeded feature request

Annotation reification with types in TH

Reported by: errge Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 7.7
Keywords: Cc: RyanGlScott
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #8397 Differential Rev(s):
Wiki Page:


The attached patch adds two simple helper functions to support typed reification of annotations. This was not in the original #8397 patch only because the typed branch was not merged at that time.

Attachments (1)

th-ann-typed.patch (1.6 KB) - added by errge 6 years ago.

Download all attachments as: .zip

Change History (10)

Changed 6 years ago by errge

Attachment: th-ann-typed.patch added

comment:1 Changed 6 years ago by errge

Status: newpatch

comment:2 Changed 6 years ago by errge

Component: CompilerTemplate Haskell

comment:3 Changed 6 years ago by errge


comment:4 Changed 6 years ago by monoidal

I like liftTyped. I would go even further and add it to the Lift class:

class Lift t where
  lift :: t -> Q Exp
  liftTyped :: t -> Q (TExp t)
  lift = unTypeQ . liftTyped
  liftTyped = unsafeTExpCoerce . lift
  {-# MINIMAL lift | liftTyped #-}

Now, when you write an instance of Lift

data A = A

instance Lift A where
  liftTyped A = [e|| A ||]

the compiler will detect if you mistakenly use a different type in the [e|| ... ||] brackets.

comment:5 Changed 6 years ago by errge

Fine with me if it gets merged it like that, thanks for the idea!

comment:6 Changed 5 years ago by thoughtpolice

Status: patchinfoneeded

Gergley, sorry for dropping this patch on the floor. As you can tell since last year a lot has changed! Can you please rebase these patches? I also vaguely remember you wrote a wiki page about what they all addressed. Thanks!

comment:7 Changed 4 years ago by thoughtpolice


Milestone renamed

comment:8 Changed 4 years ago by thomie

Milestone: 8.0.1

comment:9 Changed 3 years ago by RyanGlScott

Cc: RyanGlScott added
Note: See TracTickets for help on using tickets.