
If you're using the LPM monad, then this is about as easy as that: you use do (x1:x2:x3:_) <- newVariables ...... I mean, run is equivalent to run f = execLPM (newVariables >>= put . f) so...yeah, I think this is a reasonable solution. Alternatively, I'm almost positive there's a monad out there that lets you draw on unique values. It'd look something like type Variable = Int newtype UniqueM a = UniqueM (Variable -> (Variable, a)) -- monad instance, etc. getUnique :: UniqueM Variable getUnique = UniqueM (\ x -> (x+1, x)) Then you can use the LPT monad transformer to construct a linear program around this, just by working in the "LPT Variable c UniqueM" monad. That's actually a nicer solution than my current implementation. I'll do that, then... Louis Wasserman wasserman.louis@gmail.com http://profiles.google.com/wasserman.louis On Mon, Mar 1, 2010 at 9:29 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote:
On Sun, 28 Feb 2010, Louis Wasserman wrote:
It's an expensive operation, though -- since I don't track the set of all
variables as the LP is built, I need to construct the set of all variables before generating new ones -- so it's recommended that you get all the variables you need in one or two passes.
Then you might prefer a single operation that generates all variables and runs an enclosed problem on them:
run :: ([Variable] -> LP a) -> LP a
Use as
run $ \x0:x1:x2:_ -> do ...