seq as type class method
Roman Leshchinskiy
rl at cse.unsw.edu.au
Mon Nov 9 08:02:37 EST 2009
On 06/11/2009, at 09:50, Henning Thielemann wrote:
> Actually in stream-fusion:Data.Stream I found such a class, called
> Unlifted. How about moving this into a separate package?
>
>
> class Unlifted a where
>
> -- | This expose function needs to be called in folds/loops that
> consume
> -- streams to expose the structure of the stream state to the
> simplifier
> -- In particular, to SpecConstr.
> --
> expose :: a -> b -> b
> expose = seq
>
> -- | This makes GHC's optimiser happier; it sometimes produces
> really bad
> -- code for single-method dictionaries
> --
> unlifted_dummy :: a
> unlifted_dummy = error "unlifted_dummy"
This class serves as a vehicle for performing certain black magic
rituals which (usually) help SpecConstr destroy evil artifacts
introduced by stream fusion. In particular, expose is *not* seq; it is
essentially deepSeq.
As to single-method dictionaries, that problem existed two years or so
ago. I don't think it still happens today.
Roman
More information about the Libraries
mailing list