[Template-haskell] Reification

John O'Donnell jtod at dcs.gla.ac.uk
Thu Nov 6 14:24:16 EST 2003


Hi Simon,

> So I'm thinking that if the Type returned to you by TH contains free
> type variables, that might simply signify types that might be later
> refined.  Simple.

That sounds good, it provides the information that ghc knows in a 
way that's useful to the application.

> But not very principled, because the type you see will depend on which
> order the type checker happens to do its work in.

That's right, but this may be inevitable in a staged system.  There might
be some applications where this is a serious issue, but at least for
my work, your suggestion above would be fine - it doesn't actually matter
to me whether the free type variables get refined later.

I would like to go ahead with this proposal for reification.  I don't
know how to get around these "problems of principle", or ever whether
it is possible to solve them, but making partial type information available
would enable me to do some things that I just cannot do with the current
system.

John

Simon Peyton-Jones wrote:

>| What would be most flexible for the user is to return the best
>| information that is available.  In the example:
>| 
>| >NB This can apply to top-level decls too:
>| >	f = 1+2
>| >	$( ... reify 'f... )
>| >	g = f + (4::Int)
>| >
>| >Because of the monomorphism restriction, the type of f is fixed by
>f's
>| >caller, which may be "after" the reification.
>| >
>| it might still be useful to find out that an approximation to the type
>| is f :: Num a => a, even though that isn't the final type.  That would
>| suggest something like
>| 
>| data TypeQuery a = ExactType a  | ApproximationType a
>
>Actually, I was thinking of something more modest.  The type of f will,
>at the stage of reification, be
>	a -> a
>where a is an as-yet-refined internal type variable. If instead we had
>
>	id x = x
>
>the type would be
>	forall a. a->a
>
>So I'm thinking that if the Type returned to you by TH contains free
>type variables, that might simply signify types that might be later
>refined.  Simple.
>
>But not very principled, because the type you see will depend on which
>order the type checker happens to do its work in.
>
>Simon
>
>
>
>
>_______________________________________________
>template-haskell mailing list
>template-haskell at haskell.org
>http://www.haskell.org/mailman/listinfo/template-haskell
>
>  
>




More information about the template-haskell mailing list