Casts, and allocation

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


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)
          `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

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

Louis Wasserman
wasserman.louis at
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Glasgow-haskell-users mailing list