specializing on existentially quantified data types

Lennart Augustsson lennart at augustsson.net
Tue Nov 25 10:08:06 EST 2003


I don't know how specialised code works in ghc, so I have to ask.
Does this actually work?
The type of x is never known at the foo' call site, so the specialised
version of foo' will only be called if ghc does a run time test on the
type when invoking foo'.  Does it do that?

	-- Lennart

Simon Peyton-Jones wrote:
> | class C a where ...
> | data MkC = forall a . C a => MkC a
> | 
> | foo :: MkC -> ...
> | 
> | and I want to specialize foo for when the 'a' in the MkC is, say, Int.
> Is
> | this possible?
> 
> Not directly.  But you can say
> 
> 	foo (MkC x) = foo' x
> 
> 	foo' :: forall a. C a => a -> ...
> 	foo' x = ...
> 	{-# SPECIALISE foo' :: Int -> ... #-}
> 
> There's no built-in mechanism I'm afraid.
> 
> Simon
> 
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
> 




More information about the Glasgow-haskell-users mailing list