[GHC] #10225: GHC does not specialize based on type equality

GHC ghc-devs at haskell.org
Wed Apr 1 07:49:47 UTC 2015


#10225: GHC does not specialize based on type equality
-------------------------------------+-------------------------------------
        Reporter:  yongqli           |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.10.1
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
Description changed by yongqli:

Old description:

> Based on my testing, it seems that if I have a function like
>
> f :: (v ~ V2) => v -> v
>
> this will be slower than
>
> f :: v -> v
>
> It would be great if GHC could do this optimization. The reason I want
> this is that I have written some very generic functions in my program,
> which are actually only used for one type. SPECIALIZE doesn't seem to do
> enough, as it's hard to get those GHC to "see" all of those types. As a
> compromise, I tried to tell GHC what those types actually are via type
> equalities, so that I can keep type constraints around for the future.

New description:

 Based on my testing, it seems that if I have a function like

 f :: (v ~ V2) => v -> v

 this will be slower than

 f :: V2 -> V2

 It would be great if GHC could do this optimization. The reason I want
 this is that I have written some very generic functions in my program,
 which are actually only used for one type. SPECIALIZE doesn't seem to do
 enough, as it's hard to get those GHC to "see" all of those types. As a
 compromise, I tried to tell GHC what those types actually are via type
 equalities, so that I can keep type constraints around for the future.

--

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10225#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list