[Haskell] Re: Implicit return values

Ben Rudiak-Gould benrg at dark.darkweb.com
Sun Jan 25 18:26:17 EST 2004

Continuing my one-sided discussion:

>   newRef   :: a -> (exists s . (Ref s, ^st s a :: State))
>   readRef  :: (?st s a :: State) => Ref s -> a
>   writeRef :: Ref s -> a -> ((), ^st s a :: State)

?io and ?st should have been %io and %st, of course. It's essential that
these be linear (and that State is not an instance of Splittable).

It might also be useful to have this function:

  anotherRef :: (%st s :: State) => Ref s a -> a -> (Ref s a, ^st s :: State)

which creates a new ref in the same state space as an old one. However,
this requires that the "a" parameter be moved back to the Ref, if we want
the new ref to have an independent type. So there seem to be two kinds of
refs, serially-typed and parallel-typed, which can't share the same state
space (though they can be mixed in a single thread construct).

Another minor point: in case it wasn't clear, it should be possible to
write a type synonym like

  type IO a = (%io :: State) => (a, ^io :: State)

after which main would have the type IO (), as always.

-- Ben

More information about the Haskell mailing list