[Haskell-cafe] Re: Modelling a mutable variable store
Kannan Goundan
cakoose at yahoo.com
Sat Dec 1 22:54:05 EST 2007
On Sat, 01 Dec 2007 21:22:53 -0600, Derek Elkins wrote:
> Use ST. First-class state isn't too great unless you specifically want
> that.
I did try using ST but ran into a problem because its type variable (s)
ended up invading all of my types.
-- Target needs 's' because of the STRef
data Target s = TValue Value
| TVar (STRef s (Maybe Value))
-- Env needs 's' because Target needs 's'
type Env s = Map Ident (Target s)
-- Value needs 's' because closures are values and closures
-- have an Env.
data Value s = VUnit
| VClosure (Env s) Ident Expr
The main thing I didn't like was that 'Value' had a type parameter. I
didn't follow the ST option much past this point. But maybe there's a
better way to use ST? Will existential types help me?
- Kannan
More information about the Haskell-Cafe
mailing list