[GHC] #11028: Refactor ConDecl
GHC
ghc-devs at haskell.org
Wed Oct 28 09:18:53 UTC 2015
#11028: Refactor ConDecl
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.2
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
The `ConDecl` type in `HsDecls` is an uneasy compromise. For the most
part, `HsSyn` directly reflects the syntax written by the programmer; and
that gives just the right "pegs" on which to hang Alan's
[wiki:ApiAnnotations API annotations]. But `ConDecl` doesn't properly
reflect the syntax of Haskell-98 and GADT-style data type declarations.
To be concrete, here's a draft new data type
{{{
data ConDecl name
| ConDeclGADT
{ con_names :: [Located name]
, con_type :: LHsSigType name -- The type after the ‘::’
, con_doc :: Maybe LHsDocString
, con_old_rec :: Bool }
| ConDeclH98
{ con_name :: Located name
, con_implict :: HsImplicitBndrs ()
-- ^ Implicit binders, added by renamer
, con_qvars :: Maybe [LHsTyVarBndr name]
-- User-written foralls (if any)
, con_cxt :: Maybe (LHsContext name)
-- ^ User-written context (if any)
, con_details :: HsConDeclDetails name
-- ^ Arguments
, con_doc :: Maybe LHsDocString
-- ^ A possible Haddock comment.
} deriving (Typeable)
}}}
Note that
* For GADTs, just keep a type. That's what the user writes. (NB:
`HsType` can represent records on the LHS of an arrow: `{ x:Int,y:Bool }
-> T`
* `con_qvars` and `con_cxt` are both `Maybe` because they are both
optional (the `forall` and the context of an existential data type)
* The `con_old_rec` is a warning thing for GADTs (see current source
code)
This ticket is just to track the thought and invite feedback.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11028>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list