orphans
Simon Peyton-Jones
simonpj at microsoft.com
Fri Aug 15 19:00:07 EDT 2008
It's only an orphan if the rule's LHS mentions no locally-defined type. In this case, the LHS doesn't appear to mention IOArray, but it does really because there's an invisible type argument.
However IOArray is defined in GHC.IOBase, so indeed the rule is an orphan. Why can't the instance be put with the class decl?
S
| -----Original Message-----
| From: cvs-libraries-bounces at haskell.org [mailto:cvs-libraries-
| bounces at haskell.org] On Behalf Of Ian Lynagh
| Sent: 15 August 2008 21:33
| To: cvs-libraries at haskell.org
| Subject: orphans
|
|
| Hi all,
|
| I've been looking at removing some orphan instances (trac #2467) and hit
| difficulties.
|
| At the very bottom of the array package we have Data.Array.Base, which
| defines:
|
| class IArray a e where
| ...
| unsafeAccum = ... unsafeAccumST ...
| unsafeAccumST = ... thaw ...
| thaw = ...
|
| Now, higher up in the hierarchy, we have things like IOArrays, for which
| we want to magically turn 'thaw' into a specialised version:
|
| {-# RULES "thaw/IOArray" thaw = thawIOArray #-}
|
| but this rule is orphaned (as you can use 'thaw' in your program without
| GHC knowing that you need the IOArray module).
|
|
| I think that it would be possible to fix this, by renaming thaw to
| safeThaw and defining thaw = safeThaw higher up, in MArray.
| In MArray, we would make thaw NOINLINE but manually rewrite it to
| safeThaw in phase 2 (actually, I think we can ask GHC to INLINE it
| automatically in phase 2?), while in phase 1 we would try to rewrite it
| to thawIOArray etc if the types were suitable.
|
| Is this the best way? It seems very heavy, for such a simple problem.
|
| I feel like there should be a simpler way to deorphan it without having
| to move it, e.g.
| {-# RULES "thaw/IOArray"
| (thaw :: Array ix e -> IO (IOArray ix e)) = thawIOArray #-}
| (although that also clunky with such a large type).
|
| Ideas welcomed!
|
|
| Thanks
| Ian
|
| _______________________________________________
| Cvs-libraries mailing list
| Cvs-libraries at haskell.org
| http://www.haskell.org/mailman/listinfo/cvs-libraries
More information about the Cvs-libraries
mailing list