[GHC] #9701: GADTs not specialized properly
GHC
ghc-devs at haskell.org
Sat Oct 18 00:53:41 UTC 2014
#9701: GADTs not specialized properly
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.9
Resolution: | Keywords:
Operating System: | Architecture: Unknown/Multiple
Unknown/Multiple | Difficulty: Unknown
Type of failure: Runtime | Blocked By:
performance bug | Related Tickets:
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Description changed by dfeuer:
Old description:
> This has probably been raised before, but I can't find a ticket. If I
> write
>
> {{{#!hs
> data Silly a where
> Silly :: Ord a => a -> Silly a
>
> isItSilly :: a -> Silly a -> Bool
> isItSilly a (Silly x) = a < x
>
> isItSillyInt :: Int -> Silly Int -> Bool
> isItSillyInt = isItSilly
> }}}
>
> then I get
>
> {{{
> isItSilly
> isItSilly =
> \ @ a_aBq eta_B2 eta1_B1 ->
> case eta1_B1 of _ { Silly $dOrd_aBs x_aAy ->
> < $dOrd_aBs eta_B2 x_aAy
> }
>
> isItSillyInt
> isItSillyInt = isItSilly
> }}}
>
> Although GHC knows that `eta_B2` is an `Int`, and `x_aAy` therefore must
> be one as well, it looks up the `<` method in the `eta1_B1` dictionary
> instead of just using `ltInt`.
New description:
This has probably been raised before, but I can't find a ticket. If I
write
{{{#!hs
data Silly a where
Silly :: Ord a => a -> Silly a
isItSilly :: a -> Silly a -> Bool
isItSilly a (Silly x) = a < x
isItSillyInt :: Int -> Silly Int -> Bool
isItSillyInt = isItSilly
}}}
then I get
{{{
isItSilly
isItSilly =
\ @ a_aBq eta_B2 eta1_B1 ->
case eta1_B1 of _ { Silly $dOrd_aBs x_aAy ->
< $dOrd_aBs eta_B2 x_aAy
}
isItSillyInt
isItSillyInt = isItSilly
}}}
Although GHC knows that `eta_B2` and `x_aAy` are `Int`, it looks up the
`<` method in the `eta1_B1` dictionary instead of just using `ltInt`.
Note: it does not help to `INLINE` `isItSilly`.
--
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9701#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list