#4191: Replace -fstrict-dicts with programmer-custom strictness annotations for
class contexts
---------------------------------+------------------------------------------
Reporter: LouisWasserman | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.12.3
Keywords: | Difficulty:
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by LouisWasserman):
Okay, hard example. (Apologies for the delay while you're swamped. =( )
{{{
module Sized where
import Data.List
class Sized a where
getSize :: a -> Int
isNull :: a -> Bool
class SizeT f where
getSizeT :: Sized a => f a -> Int
isNullT :: Sized a => f a -> Bool
instance Sized Bool where
getSize False = 0
getSize True = 1
isNull = not
instance SizeT [] where
getSizeT xs = sum [getSize x | x <- xs]
isNullT = all isNull
}}}
ghc-core yields, among other methods,
{{{
Sized.$wgetSizeT :: forall a_afn.
(Sized.Sized a_afn) =>
[a_afn] -> Int#
GblId
Sized.$wgetSizeT =
\ (@ a_afn) (w_slI :: Sized.Sized a_afn) (w1_slJ :: [a_afn]) ->
letrec {
go_slT :: [a_afn] -> [Int]
LclId
[Arity 1
go_slT =
\ (ds_akU :: [a_afn]) ->
case ds_akU of _ {
[] -> [] @ Int;
: y_akZ ys_al0 ->
:
@ Int
(case w_slI of _ { Sized.D:Sized tpl1_B2 _ -> tpl1_B2
y_akZ })
(go_slT ys_al0)
}; } in
Data.List.$wsum' (go_slT w1_slJ) 0
}}}
which re-forces the dictionary for every list element, whereas I'd hope to
see
{{{
Sized.$wgetSizeT :: forall a_afn.
(Sized.Sized a_afn) =>
[a_afn] -> Int#
GblId
Sized.$wgetSizeT =
\ (@ a_afn) (w_slI :: Sized.Sized a_afn) (w1_slJ :: [a_afn]) ->
case w_slI of _ { Sized.D:Sized tpl1_B2 _ ->
letrec {
go_slT :: [a_afn] -> [Int]
LclId
[Arity 1
go_slT =
\ (ds_akU :: [a_afn]) ->
case ds_akU of _ {
[] -> [] @ Int;
: y_akZ ys_al0 ->
:
@ Int
(w_slI y)
(go_slT ys_al0)
}; } in
Data.List.$wsum' (go_slT w1_slJ) 0
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4191#comment:8>
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