
For the reasons talked about in previous posts, I'd like to propose a
deepSeq
for Haskell'.
- It provides a mechanism to allow an effective, systematic
tracking down of
a class of space leaks.
- It provides a mechanism to simply stomp on a class of space leaks.
- It avoids the user having to explicitly declare instances for a
homebrew deepSeq
for every type in your program.
- It has a declarative feel; this expression is hyper strict.
- Is a specification of strictness.
- It will open up various optimization opportunities, avoiding
building thunks.
(I dont talk about this more, but I'm happy to elaborate)
- It can have an efficient implementation, or a simple (slow)
implementation.
(The fast implementation one can be used to stomp space leaks,
the slow one can help find the same leaks.)
What I would like to propose for Haskell' are four things:
(Essential) Add a deepSeq function into Haskell'
deepSeq :: a -> b -> b
- Don't really care if its in a class or not; would prefer not for
the reasons John Hughes talked about.
- This would deepSeq all its children for regular constructors.
- deepSeq would not indirect into IO or MVar.
- functions would be evaluated to (W?)HNF.
- IO, ST are functions under the hood.
(Easy) Add a $!! function, and a strict function
f $!! a = a `deepSeq` f a
strict a = a `deepSeq` a
(Nice) Add a !! notation, where we have ! in datatypes.
data StrictList a = Cons (!!a) (!!StrictList a) | Nil
(Perhaps) Add a way of making *all* the fields strict/hyperstrict.
data !!StrictList a = ..,
We could also do this for !
--------------
Implementation:
deepSeq (RAW_CONS