From: Axel S. <A....@ke...> - 2004-05-05 07:25:46
|
On 4 May 2004, at 00:16, Duncan Coutts wrote: > So, you can see that the to* from* functions are just casting pointers, > except that the pointers are wrapped in newtypes. The existing > mechanism > uses class methods to cast away the newtype. My proposal is to cast > directly (which is safe because newtypes do not change representation > and casting pointer using unsafeCoerce is also safe). The external > types > have not changed to the use of unsafeCoerce# is not exposed to the > user. To actually get rid of class contexts, we would have to take the to* and from* functions out of the class: toContainer :: ObjectClass o => o -> Container toContainer = unsafeCoerce I guess that GHC will remove the whole class context in this case (since it is not used). This would be a (small) gain if GHC cannot inline these functions when they are passed as a dictionary (I can imagine that GHC can never do that, but I never looked at the core produced). If all the changes are restricted to Hierarchy.chs, then it's alright to commit since it's easily reverted. Axel. |