#2762: Excessive heap usage
---------------------------------+------------------------------------------
Reporter: igloo | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 6.10.2
Component: Compiler | Version: 6.11
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Os: Unknown/Multiple
Architecture: Unknown/Multiple |
---------------------------------+------------------------------------------
Comment (by igloo):
I think I can work around the cases of this in my real program by pulling
the instance methods out into recursive functions, e.g.
{{{
instance InputOutput a => InputOutput [a] where
input = inputList
inputList :: InputOutput a => String -> ([a], String)
inputList ('0':bs) = ([], bs)
inputList ('1':bs) = case input bs of
(x, bs') ->
case inputList bs' of
~(xs, bs'') -> (x : xs, bs'')
}}}
In some cases it gets a little uglier, but still tolerable, e.g. with:
{{{
data Seq p from to where
Cons :: p from mid -> Seq p mid to -> Seq p from to
Nil :: Seq p here here
}}}
I need to hide the `from` and `to` arguments to stop it leaking space:
{{{
data Hide2 t where
Hide2 :: t a b -> Hide2 t
hide2 :: t a b -> Hide2 t
hide2 x = Hide2 x
unhide2 :: Hide2 t -> t a b
unhide2 (Hide2 x) = unsafeCoerce x
inputSeq :: InputOutput2 p => ByteString -> (Hide2 (Seq p), ByteString)
inputSeq bs = case BS.head bs of
0 -> (hide2 Nil, BS.tail bs)
1 -> case input2 (BS.tail bs) of
(x, bs') ->
case inputSeq bs' of
~(xs, bs'') ->
(hide2 (x `Cons` unhide2 xs), bs'')
_ -> error "InputOutput Seq: Bad value"
}}}
So I'd still like this to be fixed, as it would be one less thing to worry
about when writing code, but I don't think it's actually blocking me
currently.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2762#comment:6>
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