[Haskell] Re: Implicit return values
Ben Rudiak-Gould
benrg at dark.darkweb.com
Sun Jan 25 17:41:30 EST 2004
I wrote:
> newRef :: a -> (exists s . Ref s a, ^st s :: State)
> readRef :: (?st s :: State) => Ref s a -> (a, ^st s :: State)
> writeRef :: (?st s :: State) => Ref s a -> a -> ((), ^st s :: State)
>
> (It's not clear that readRef actually needs to return the state.)
It shouldn't, and neither should writeRef need to *take* the state. And
the type a should be moved from the ref to the state parameter. I think
this gives us statically safe polymorphic refs. And I forgot some
parentheses in newRef. I think these are the right types:
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)
-- Ben
More information about the Haskell
mailing list