RE: SPECIALIZE function for type defined elsewhere

2010-07-28 Thread Simon Peyton-Jones
| SPECIALISE pragmas are not supported in any but the defining module | because the Core for a function to specialise is not guaranteed to be | available in any other module. I don't think there is any other | barrier. Yes, exactly. | It is possible to imagine implementing a remedy for this by us

Re: SPECIALIZE function for type defined elsewhere

2010-07-28 Thread Sebastian Fischer
On Jul 28, 2010, at 5:40 PM, Max Bolingbroke wrote: SPECIALISE pragmas are not supported in any but the defining module because the Core for a function to specialise is not guaranteed to be available in any other module. Would it be reasonable (and possible) to reject specialization only if

Re: SPECIALIZE function for type defined elsewhere

2010-07-28 Thread Max Bolingbroke
On 28 July 2010 13:57, Sebastian Fischer wrote: > In my case, I don't want to put everything in a single module because I > cannot know what other B-like modules people will implement.Are they bound > to use `f` unspecialized for their types? Yes. GHC might inline "f" into the call site and achie

SPECIALIZE function for type defined elsewhere

2010-07-28 Thread Sebastian Fischer
Dear GHC experts, say I have module A where class C a where ... f :: C a => String -> a module B where import A data T = ... instance C T where ... g :: String -> SomeOtherType g s = doSomethingWith (f s) Is it possible to SPECIALIZE `f` for the type `T`? I