Newtype wrappers in hsSyn

Simon Peyton-Jones simonpj at microsoft.com
Wed Jan 27 10:14:03 EST 2010


| I was wondering whether there would be any concerns against redefining the
| above type synonyms into newtypes?  Either each one of the above gets its own
| newtype wrapper or new phase-describing wrappers:
|
|  newtype PostTc a = PostTc a deriving (Eq, Ord, Show, Functor)
|  newtype PostRn a = PostRn a deriving (Eq, Ord, Show, Functor)
|
|  type PostTcType = PostTc Type
|  type PostTcExpr = PostTc (HsExpr Id)
|  type SyntaxExpr id = PostRn (HsExpr id)
|  -- etc.
|
| The default instances would ignore any Post* types, but they could easily be
| added via custom `ext1T` and friends.

That'd be fine.  Go ahead.

| These have always distressed me. Would it be feasible to refactor so
| that this isn't necessary, e.g.
|
|     typecheck :: HsSyn Name () -> HsSyn Name PostTcInfo

I don't particularly like it either, but it's never caused problems.  Adding several more type parameters to all the HsSyn types just feels like a rather heavyweight solution to something that isn't really biting us.

Also I don't want to do that right now, because I'm upheaving the type checker, so I don't want major changes.  (Adding the newtypes is fine though.)

Simon



More information about the Cvs-ghc mailing list