Created
April 10, 2012 12:12
-
-
Save bluescreen303/2350944 to your computer and use it in GitHub Desktop.
workaround for UHC bug http://code.google.com/p/uhc/issues/detail?id=53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/reactive-banana/src/Reactive/Banana/Internal/CompileModel.hs b/reactive-banana/src/Reactive/Banana/Internal/CompileModel.hs | |
index a9b78df..c3e07e8 100644 | |
--- a/reactive-banana/src/Reactive/Banana/Internal/CompileModel.hs | |
+++ b/reactive-banana/src/Reactive/Banana/Internal/CompileModel.hs | |
@@ -27,12 +27,15 @@ import Reactive.Banana.Model | |
data InputToEvent = InputToEvent (forall a. InputChannel a -> Event a) | |
type Compile a b = (InputToEvent -> IO (Event a,b)) -> IO (Automaton a,b) | |
+ | |
+data Box a = Box { unBox :: a } | |
+ | |
compileWithGlobalInput :: Compile a b | |
compileWithGlobalInput f = do | |
-- reference that holds input values | |
- (ref :: IORef [InputValue]) <- newIORef undefined | |
+ (ref :: IORef (Box [InputValue])) <- newIORef (Box undefined) | |
-- An infinite list of all future input values. Very unsafe! | |
- (inputs :: Event [InputValue]) <- unsafeSequence (Just <$> readIORef ref) | |
+ (inputs :: Event [InputValue]) <- unsafeSequence (Just . unBox <$> readIORef ref) | |
let | |
inputToEvent = InputToEvent $ | |
@@ -46,7 +49,7 @@ compileWithGlobalInput f = do | |
-- step of the automaton | |
step values outputs = do | |
- writeIORef ref values -- write new input value | |
+ writeIORef ref (Box values) -- write new input value | |
(o:outputs) <- evaluate outputs -- make sure that output is in WHNF | |
return (o, outputs) -- return result | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment