#5835: Make better use of known dictionaries
------------------------------+---------------------------------------------
Reporter: rl | Owner:
Type: feature request | Status: new
Priority: normal | Component: Compiler
Version: 7.5 | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: None/Unknown | Testcase:
Blockedby: | Blocking:
Related: |
------------------------------+---------------------------------------------
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.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5835>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs