Casts, and allocation

Louis Wasserman wasserman.louis at gmail.com
Fri Jul 2 13:53:38 EDT 2010


Hey,

I was wondering how difficult it would be to improve handling of casts, as
follows:  when looking at Core, I see things like

    (\ (ds_dcKZ :: Data.TrieMap.TrieKey.TrieMap
                     (Data.TrieMap.Regular.Base.App f_XcwB k_XcwD) a_acAi)
->
       f_scPr
         (ds_dcKZ
          `cast` (trans
                    (Data.TrieMap.Regular.App.TFCo:R:TrieMapAppa f_XcwB
k_XcwD a_acAi)
                    (Data.TrieMap.Regular.App.NTCo:R:TrieMapAppa f_XcwB
k_XcwD a_acAi)
                  :: Data.TrieMap.TrieKey.TrieMap
                       (Data.TrieMap.Regular.Base.App f_XcwB k_XcwD) a_acAi
                       ~
                     Data.TrieMap.Regular.Class.TrieMapT f_XcwB k_XcwD
a_acAi)))

which is equivalent to a single cast of f.  I get that generalized newtype
deriving does something like this automatically -- unfortunately, at the
moment, I'm using a class with associated types, so I can't do that.

How difficult would it be to identify and rewrite these, when they appear in
non-recursive lets?  (I'm actually experimenting with implementing the
change myself, but I've never hacked GHC before, so we'll see how it
goes...)

Louis Wasserman
wasserman.louis at gmail.com
http://profiles.google.com/wasserman.louis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20100702/21caba3d/attachment.html


More information about the Glasgow-haskell-users mailing list