Polymorphic strict fields
duncan.coutts at worc.ox.ac.uk
Tue May 1 15:00:08 EDT 2007
On Tue, 2007-05-01 at 09:50 -0700, Iavor Diatchki wrote:
> On 5/1/07, Duncan Coutts <duncan.coutts at worc.ox.ac.uk> wrote:
> > On Mon, 2007-04-30 at 19:47 -0700, Iavor Diatchki wrote:
> > > All of this leads me to think that perhaps we should not allow
> > > strictness annotations on polymorphic fields. Would people find this
> > > too restrictive?
> > Yes.
> > Our current implementation of stream fusion relies on this:
> > data Stream a = forall s. Unlifted s =>
> > Stream !(s -> Step a s) -- ^ a stepper function
> > !s -- ^ an initial state
> > We use strictness on polymorphic (class constrained) fields to simulate
> > unlifted types. We pretend that the stream state types are all unlifted
> > and have various strict/unlifted type constructors:
> This declaration uses existential and not universal quantification.
> More concretely, there exists some type that classifies the state of
> the stream but the users of the stream do not know what it is (by the
> way I saw Don talk about this stream stuff and I think that it is
> quite cool!). A polymorphic field is one where the ``forall`` is
> associated with the field (it comes after the constructor), it allows
> you to store polymorphic values in a datatype.
Ah ok. When you said "strictness annotations on polymorphic fields" I
assumed you meant just ordinary things like:
data A a = A !a
rather than local universal quantification.
More information about the Haskell-prime