Opened 6 years ago

Closed 5 years ago

#3497 closed feature request (fixed)

Template Haskell support for GADTs

Reported by: simonpj Owned by:
Priority: normal Milestone: 7.0.1
Component: Compiler Version: 6.10.4
Keywords: Cc: andres@…, philip.weaver@…, MartijnVanSteenbergen, ariep@…, tora@…, illissius@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

Andres Loh asks that Template Haskell supports GADTs.

Related tickets: #2399 (support view patterns), #1262 (support mdo/do rec).

Really all that is needed here is for some motivated person to

  • Design the data types in Language.Haskell.TH.Syntax
  • Get a consensus that the design is a good one
  • Update pretty printers etc
  • Add conversions to and from from HsSyn to TH.Syntax (these are in hsSyn/Convert.lhs and deSugar/DsMeta.lhs).

For the first two steps, the best plan might be to use the libraries process (ie make a proposal, give a discussion period etc).

Change History (7)

comment:1 Changed 6 years ago by guest

  • Cc ariep@… added

comment:2 Changed 6 years ago by TristanAllwood

  • Cc tora@… added
  • Type of failure set to None/Unknown

comment:3 Changed 5 years ago by igloo

  • Milestone changed from 6.14 branch to 6.14.1

comment:4 Changed 5 years ago by simonpj

A related question is that of reifying type-class instances. Here there is a bit more design to do. I suppose you might want to add a new method to Quasi, something like

  qReifyInstances :: Pred -> m InstanceInfo

Here the idea is that to get all the instances matching, say (C [a]) you'd give that predicate to qReifyInstances and it'd return all the matching instances.

See http://www.mail-archive.com/[email protected]/msg13057.html for example.

comment:5 Changed 5 years ago by Ashley Yakeley

+1

comment:6 Changed 5 years ago by illissius

  • Cc illissius@… added

comment:7 Changed 5 years ago by simonpj

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

OK this is done:

  • For reifying instances see #1480
  • For GADTs, TH syntax is now expressive enough to reify GADTs, albeit slightly oddly. A GADT
    data Con = NormalC Name [StrictType]          -- ^ @C Int a@
             | RecC Name [VarStrictType]          -- ^ @C { v :: Int, w :: a }@
             | InfixC StrictType Name StrictType  -- ^ @Int :+ a@
             | ForallC [TyVarBndr] Cxt Con        -- ^ @forall a. Eq a => C [a]@
    

The ForallC form of constructor can express GADTs because the Cxt can include equality constraints.

Simon

Note: See TracTickets for help on using tickets.