Ticket #5835 (new feature request)
Make better use of known dictionaries
| Reported by: | rl | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.6.2 |
| Component: | Compiler | Version: | 7.5 |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
Example:
data T a where
T :: Eq a => a -> T a
foo :: a -> T a -> Bool
{-# INLINE foo #-}
foo x = \(T y) -> x == y
appl :: (a -> b) -> a -> b
{-# NOINLINE appl #-}
appl f x = f x
bar :: T Int -> Bool
bar t = appl (foo 42) t
GHC generates this for bar:
bar2 :: Int
bar2 = I# 42
bar1 :: T Int -> Bool
bar1 =
\ (ds_dhk :: T Int) ->
case ds_dhk of _ { T $dEq_agz y_aa4 ->
== @ Int $dEq_agz bar2 y_aa4
}
bar :: T Int -> Bool
bar = \ (t_aga :: T Int) -> appl @ (T Int) @ Bool bar1 t_aga
Note how it want to get the Eq dictionary for Int from T. But we know the Eq Int instance without inspecting T and bar could be significantly simplified if we used that.
Change History
Note: See
TracTickets for help on using
tickets.
