SPECIALIZE pragma

Ross Paterson ross at soi.city.ac.uk
Mon Jun 28 07:28:15 EDT 2004


On Thu, Jun 17, 2004 at 10:53:28AM +0100, I wrote:
> Digging around in the source code comments, I found a restriction that
> is biting me:
> 
> > We *insist* that all overloaded type variables are specialised to ground
> > types, (and hence there can be no context inside a SPECIALIZE pragma).
> 
> The latter is fine, but the former seems too restrictive.  For example,
> a function with constraints (Storable a, Eq a) can't be specialized to
> Ptr b, even though b would be unconstrained.  Any hope of relaxing this?

After a bit of experimentation: if we have

	f :: (Storable a, Eq a) => T a
	{-# SPECIALIZE f :: T (Ptr a) #-}

not only do we not get the requested polymorphic specialization, but
if we use f at the ground types T (Ptr Foo) and T (Ptr Bar), we get a
specialization for each, and these are essentially the same.  Is there
any reason not to generate the polymorphic one?


More information about the Glasgow-haskell-users mailing list