Skip to content

Instantly share code, notes, and snippets.

@agocorona
Created January 19, 2018 08:55
Show Gist options
  • Select an option

  • Save agocorona/c66d4ab70188687657712dcd16206b35 to your computer and use it in GitHub Desktop.

Select an option

Save agocorona/c66d4ab70188687657712dcd16206b35 to your computer and use it in GitHub Desktop.
Eta MVar test
import Control.Monad
import Control.Applicative
import Control.Concurrent.MVar hiding (takeMVar, putMVar)
import qualified Control.Concurrent.MVar as MVar
import Control.Concurrent.Fiber
import Control.Concurrent.Fiber.MVar
import System.Environment
import GHC.Conc.Sync hiding (yield)
import GHC.Conc.IO
import Control.Monad.IO.Class
main= runFiber$ do
r <- liftIO newEmptyMVar
loop r
loop r= do
putMVar r "hello"
s <- takeMVar r
liftIO $ print s
trampolineFiber $ loop r
trampolineFiber x= liftIO $ trampolineIO $ runFiber x
Exception in thread "main" java.lang.StackOverflowError
at eta.runtime.storage.CachedBlock.getBlock(CachedBlock.java:28)
at eta.runtime.io.MemoryManager.getBlock(MemoryManager.java:86)
at eta.runtime.io.MemoryManager.getInt(MemoryManager.java:126)
at base.ghc.io.encoding.UTF8.$wa(UTF8.hs:226)
at base.ghc.io.encoding.UTF8.mkUTF1(UTF8.hs)
at base.ghc.io.encoding.UTF8$mkUTF1.apply2V(UTF8.hs)
at base.ghc.io.handle.Internals$a2_sHKZZD.apply2V(Internals.hs:379)
at base.ghc.io.handle.Internals.$wa(Internals.hs:372)
at base.ghc.io.handle.Internals.$wa6(Internals.hs:510)
at base.ghc.io.handle.Text$sat_sI5WS.apply1V(Text.hs:605)
at base.ghc.io.handle.Internals$sat_sHMLY.apply1V(Internals.hs:255)
at eta.runtime.apply.PAP1_1.applyV(PAP1_1.java:17)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:117)
at eta.runtime.exception.Exception.catch_(Exception.java:129)
at base.ghc.io.handle.Internals.$wa2(Internals.hs:166)
at base.ghc.io.handle.Internals$a3_sHMD0.applyV(Internals.hs:132)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at base.ghc.io.handle.Internals.$wa4(Internals.hs:130)
at base.ghc.io.handle.Internals.$wa3(Internals.hs:236)
at base.ghc.io.handle.Internals.wantWritableHandle1(Internals.hs:226)
at base.ghc.io.handle.Text.$wa7(Text.hs:630)
at base.ghc.io.handle.Text.hPutStr2(Text.hs:553)
at main.Main$lvl1_s9YQ.apply1V(testmvar.hs:21)
at main.control.concurrent.fiber.MVar$a1_s6ME.apply1V(MVar.hs:21)
at eta.runtime.apply.PAP1_1.applyV(PAP1_1.java:17)
at eta.runtime.apply.Function1.apply1V(Function1.java:14)
at main.control.concurrent.fiber.MVar$a1_s6N3.apply1V(MVar.hs:32)
at eta.runtime.apply.PAP1_1.applyV(PAP1_1.java:17)
at eta.runtime.apply.Function1.apply1V(Function1.java:14)
at main.Main$sat_s9ZZ0.thunkEnter(testmvar.hs:23)
at eta.runtime.thunk.UpdatableThunk.evaluate(UpdatableThunk.java:24)
at eta.runtime.thunk.Thunk.enter(Thunk.java:45)
at eta.runtime.stg.Stg.trampoline(Stg.java:92)
at main.Main$lvl1_s9YQ.apply1V(testmvar.hs:23)
at main.control.concurrent.fiber.MVar$a1_s6ME.apply1V(MVar.hs:21)
at eta.runtime.apply.PAP1_1.applyV(PAP1_1.java:17)
at eta.runtime.apply.Function1.apply1V(Function1.java:14)
at main.control.concurrent.fiber.MVar$a1_s6N3.apply1V(MVar.hs:32)
at eta.runtime.apply.PAP1_1.applyV(PAP1_1.java:17)
at eta.runtime.apply.Function1.apply1V(Function1.java:14)
at main.Main$sat_s9ZZ0.thunkEnter(testmvar.hs:23)
at eta.runtime.thunk.UpdatableThunk.evaluate(UpdatableThunk.java:24)
at eta.runtime.thunk.Thunk.enter(Thunk.java:45)
at eta.runtime.stg.Stg.trampoline(Stg.java:92)
at main.Main$lvl1_s9YQ.apply1V(testmvar.hs:23)
at main.control.concurrent.fiber.MVar$a1_s6ME.apply1V(MVar.hs:21)
at eta.runtime.apply.PAP1_1.applyV(PAP1_1.java:17)
at eta.runtime.apply.Function1.apply1V(Function1.java:14)
at main.control.concurrent.fiber.MVar$a1_s6N3.apply1V(MVar.hs:32)
at eta.runtime.apply.PAP1_1.applyV(PAP1_1.java:17)
at eta.runtime.apply.Function1.apply1V(Function1.java:14)
at main.Main$sat_s9ZZ0.thunkEnter(testmvar.hs:23)
at eta.runtime.thunk.UpdatableThunk.evaluate(UpdatableThunk.java:24)
at eta.runtime.thunk.Thunk.enter(Thunk.java:45)
at eta.runtime.stg.Stg.trampoline(Stg.java:92)
at main.Main$lvl1_s9YQ.apply1V(testmvar.hs:23)
at main.control.concurrent.fiber.MVar$a1_s6ME.apply1V(MVar.hs:21)
at eta.runtime.apply.PAP1_1.applyV(PAP1_1.java:17)
at eta.runtime.apply.Function1.apply1V(Function1.java:14)
at main.control.concurrent.fiber.MVar$a1_s6N3.apply1V(MVar.hs:32)
at eta.runtime.apply.PAP1_1.applyV(PAP1_1.java:17)
at eta.runtime.apply.Function1.apply1V(Function1.java:14)
at main.Main$sat_s9ZZ0.thunkEnter(testmvar.hs:23)
at eta.runtime.thunk.UpdatableThunk.evaluate(UpdatableThunk.java:24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment