Re: [JVM-B] The best way to use a JVMBridge-based module.
Status: Beta
Brought to you by:
ashley-y
From: Artem Gr <ar...@bi...> - 2006-12-22 19:28:25
|
Ok, attached is the case of the Java function called repeatedly from the IO monad (the third case in the "test" function). That is, we don't need to write the whole program inside the JVM monad, instead we can pass the necessary state variables (vm and env) to the functions working with the JVM, while keeping the rest of the program in the IO monad. That means we can write JVM-Bridge based modules whose JVM state is transparent to the user. Artem Gr wrote: > What i'm currently bothered with, is the imposing requirement of the > JVM monad on the user of the module. > Is it possible to do (in the user code): > > main = runWithClasspath cp do > jdbc <- jdbcDriverConnection ... > callIO (mainProg jdbc) > mainProg jdbc = do > rs <- query "select 0 from dual" jdbc > close jdbc > > That is, to wrap the created JVM monad in the "jdbc" variable and wrap > all the JDBC functions except the jdbcDriverConnection in the IO > monad, but make them do the JVM monad work inside. I suppose it is > somehow possible by merging the IO and JVM monads into another monad, > but i haven't yet used such mechanics. > > That is, is it possible to write the "callJVM" function, which, like > "callIO", invokes the code inside the JVM monad (without trying to > create a second JVM every time). |