#13733: Simplify constraints on RULES LHS
-------------------------------------+-------------------------------------
Reporter: nomeata | Owner: (none)
Type: feature | Status: new
request |
Priority: normal | Milestone:
Component: Compiler | Version: 8.3
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
TL;DR: Rewrite rules should be able to match instance methods.
I know that the interaction of rewrite rules and classes/instances/methods
is unsatisfying, and probably will be for the forseeable future given the
current design. But we might still improve little bits.
Consider this code:
{{{
{-# RULES
"[Integer] Eq Refl" forall (xs :: [Integer]). xs == xs = True
#-}
}}}
This is the best I can to express the intention of “dear compile, this is
a rule for the equality on lists if the elements are integers”. But what I
get is
{{{
"[Integer] Eq Refl" [ALWAYS]
forall ($dEq_a1Jv :: Eq [Integer]) (xs_a1Hd :: [Integer]).
== @ [Integer] $dEq_a1Jv xs_a1Hd xs_a1Hd
= GHC.Types.True
}}}
which is a rule about the method `==` applied to ''any'' evidence of
equality about lists. This works in the most obvious cases, such as
{{{
alwaysTrue :: [Integer]-> Bool
alwaysTrue xs = xs == xs
}}}
but it does not fire with
{{{
delayedId :: a -> a
delayedId x = x
{-# INLINE [0] delayedId #-}
alwaysTrue :: [Integer]-> Bool
alwaysTrue xs = xs == delayedId xs
{-# NOINLINE alwaysTrue #-}
}}}
The reason is that directly after the simplifier, in the former case, the
Core looks like this
{{{
$dEq_a1HH :: Eq [Integer]
[LclId, Str=DmdType]
$dEq_a1HH = GHC.Classes.$fEq[] @ Integer integer-
gmp-1.0.0.1:GHC.Integer.Type.$fEqInteger
alwaysTrue [InlPrag=NOINLINE] :: [Integer] -> Bool
[LclIdX, Str=DmdType]
alwaysTrue = \ (xs_aGT :: [Integer]) -> == @ [Integer] $dEq_a1HH xs_aGT
xs_aGT
}}}
which matches the rule, but in the latter case, by the time the
`delayedId` is out of the way, we have
{{{
alwaysTrue [InlPrag=NOINLINE] :: [Integer] -> Bool
[LclIdX, Arity=1, Str=DmdType <S,U>]
alwaysTrue =
\ (xs_aGT :: [Integer]) ->
GHC.Classes.$fEq[]_$c==
@ Integer
integer-gmp-1.0.0.1:GHC.Integer.Type.$fEqInteger
xs_aGT
xs_aGT
}}}
One possible way forward would be to simplify the wanted constraints on
the LHS of the rule using the instances in scope:
{{{
"[Integer] Eq Refl" [ALWAYS]
forall (xs_a1Hd :: [Integer]).
GHC.Classes.$fEq[]_$c==
@ Integer
integer-gmp-1.0.0.1:GHC.Integer.Type.$fEqInteger
xs_a1Hd
xs_a1Hd
= True
}}}
This might be tricky, of course, as this requires not only help from the
type checker, but also some careful tuned simplification of the LHS
afterwards (e.g. unfold dictionary accessors)).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13733>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#13092: family instance consistency checks are too pessimistic
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner: rwbarton
Type: bug | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 8.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Compile-time
Unknown/Multiple | performance bug
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
FamInst has this logic for checking type family instance consistency among
imports:
{{{
Note [Checking family instance consistency]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For any two family instance modules that we import directly or indirectly,
we
check whether the instances in the two modules are consistent, *unless* we
can
be certain that the instances of the two modules have already been checked
for
consistency during the compilation of modules that we import.
[...]
How do we know which pairs of modules have already been checked? Any pair
of
modules where both modules occur in the `HscTypes.dep_finsts' set (of the
`HscTypes.Dependencies') of one of our directly imported modules must have
already been checked. Everything else, we check now. (So that we can be
certain that the modules in our `HscTypes.dep_finsts' are consistent.)
}}}
However, suppose one of the modules `A` we import directly is itself a
type family instance module. Then it too has been checked for consistency
with its dependencies `B`, `C`, etc., so we should skip checking the pairs
`A` & `B`, `A` & `C`, etc.
The current behavior means that whenever we directly import a type family
instance module, we still have to load the interface files for all its
type family module dependencies, which largely defeats the purpose of the
optimization in this case.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13092>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#13629: sqrt should use machine instruction on x86_64
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.4.1
Component: Compiler | Version: 8.0.1
(NCG) |
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Runtime
Unknown/Multiple | performance bug
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): Phab:D3265 | Wiki Page:
-------------------------------------+-------------------------------------
The NCG currently implements the square root MachOp with an out-of-line
call. This resulted in a large performance regression in `n-body` (see
#13570). Fix this.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13629>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#13734: Code requires ScopedTypeVariables, possibly erroneously
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
This doesn't work without `ScopedTypeVariables`, but shouldn't it? (on
`8.0.1`, 8.2.0.20170507`)
{{{#!hs
{-# Language ScopedTypeVariables, TypeApplications, AllowAmbiguousTypes,
InstanceSigs #-}
class Sized f where
size :: Int
instance Sized Int where
size :: Int
size = 42
instance (Sized a, Sized b) => Sized (a, b) where
size :: Int
size = size @a + size @b
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13734>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#9445: GHC Panic: Tick Exhausted with high factor
-------------------------------------+-------------------------------------
Reporter: adinapoli | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.3
Keywords: panic | Operating System: MacOS X
Architecture: Unknown/Multiple | Type of failure:
Difficulty: Unknown | None/Unknown
Blocked By: | Test Case:
Related Tickets: 5539 | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Hello guys,
this is an old bug which has been reported so many times that I'm not sure
this will be noise or something useful.
In a nutshell I have been hit by this bug installing the library "SFML",
which relies heavily on FFI.
The only interesting thing of this report is that it was necessary an very
high simpl-factor to make the installation go through!
Pre-bump:
{{{
Resolving dependencies...
In order, the following will be installed:
SFML-0.2.0.0 (reinstall)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
Configuring SFML-0.2.0.0...
Building SFML-0.2.0.0...
Preprocessing library SFML-0.2.0.0...
[...]
[34 of 71] Compiling SFML.Graphics.Transform (
dist/build/SFML/Graphics/Transform.hs,
dist/build/SFML/Graphics/Transform.o )
ghc: panic! (the 'impossible' happened)
(GHC version 7.8.3 for x86_64-apple-darwin):
Simplifier ticks exhausted
When trying UnfoldingDone $j_sZQW{v} [lid]
To increase the limit, use -fsimpl-tick-factor=N (default 100)
If you need to do this, let GHC HQ know, and what factor you needed
To see detailed counts use -ddump-simpl-stats
Total ticks: 2655928
}}}
And this was the magic line:
{{{
cabal install SFML --ghc-option=-fsimpl-tick-factor=1630
}}}
HTH, it turns out it's quite an annoying one! And yes, "1630" was the
smaller factor which made the installation possible.
Alfredo
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9445>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler