Panic when using syb with GHC API
Max Bolingbroke
batterseapower at hotmail.com
Fri Aug 26 18:53:06 CEST 2011
On 26 August 2011 09:22, Simon Peyton-Jones <simonpj at microsoft.com> wrote:
> The underlying issue is that before type checking GHC (obviously) doesn't know the types of things, while afterwards it does. The whole HsSyn tree is parameterised over the types of identifiers:
>
> Parsed: HsExpr RdrNames
> Renamed: HsExpr Name
> Typechecked: HsExpr Id
>
> One alternative would be to parameterise the tree over the type of type-decorations, so instead of 'PostTcType' you'd have 'ty' (a variable) instead. So we'd have
>
> Renamed: HsExpr Name ()
> Typechecked: HsExpr Id Type
>
> To me this seems like a bit of a sledgehammer to crack a nut; and I think there are a couple of other similar things (like SyntaxExpr). But it might be possible.
Type functions?
data HsExpr name = ... | HasTypeArgument (TypeInfo name)
type family TypeInfo name :: *
type instance TypeInfo RdrName = ()
type instance TypeInfo Name = Type
This basically lets you get away with just a single type index to
HsExpr and friends.
Max
More information about the Glasgow-haskell-users
mailing list