Skip to content

Commit 37d8d22

Browse files
committed
code elimination
1 parent d100cfe commit 37d8d22

File tree

2 files changed

+39
-35
lines changed

2 files changed

+39
-35
lines changed

axiom/tests/test.hs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env execthirdlinedocker.sh
22
-- info: use sed -i 's/\r//g' file if report "/usr/bin/env: ‘execthirdlinedocker.sh\r’: No such file or directory"
3-
-- LIB="/projects/transient-stack" && mkdir -p static && ghcjs -DDEBUG --make -i${LIB}/transient/src -i${LIB}/transient-universe/src -i${LIB}/axiom/src $1 -o static/out && runghc -DDEBUG -i${LIB}/transient/src -i${LIB}/transient-universe/src -i${LIB}/axiom/src $1 ${2} ${3}
3+
-- LIB="/projects/transient-stack" && mkdir -p static && ghcjs -DDEBUG --make -i${LIB}/transient/src -i${LIB}/transient-universe/src -i${LIB}/axiom/src $1 -o static/out && runghc -DDEBUG -w -i${LIB}/transient/src -i${LIB}/transient-universe/src -i${LIB}/axiom/src $1 && `dirname $1`/`basenane $1` $2 $3
4+
5+
46
{-# LANGUAGE CPP #-}
57
import GHCJS.HPlay.View
68
import Control.Applicative
@@ -12,18 +14,16 @@ import qualified Network.WebSockets.Connection as WS
1214
import Data.IORef
1315
import qualified Data.ByteString.Lazy.Char8 as BS
1416
#endif
15-
main = keep $ initNode action
1617

17-
action :: Cloud ()
18-
action = do
18+
main = keep $ initNode $ do
1919
local $ setRState (0::Int)
20-
onAll $ liftIO $ print ("ACTION" ::String)
20+
2121
local $ render $ wbutton "hello" (toJSString "try this")
2222

23+
2324
r <- local $ getRState <|> return 0
2425
local $ setRState $ r + 1
25-
atRemote $ local $ do
26-
liftIO $ print r
26+
atRemote $ localIO $ print r
2727

2828
local $ render $ wraw (h1 (r :: Int))
2929

transient-universe/src/Transient/Move/Internals.hs

+32-28
Original file line numberDiff line numberDiff line change
@@ -1203,33 +1203,37 @@ mread conn= do
12031203
-- liftIO $ modifyMVar_ (isBlocked conn) $ const $ Just <$> return t
12041204
-- deserialize
12051205
-- where
1206-
-- perform timeouts and cleanup of the server when connections close
1207-
receiveData' :: Connection -> NWS.Connection -> IO BS.ByteString
1208-
receiveData' c conn = do
1209-
msg <- WS.receive conn
1210-
tr ("RECEIVED",msg)
1211-
case msg of
1212-
NWS.DataMessage _ _ _ am -> return $ NWS.fromDataMessage am
1213-
NWS.ControlMessage cm -> case cm of
1214-
NWS.Close i closeMsg -> do
1215-
hasSentClose <- readIORef $ WS.connectionSentClose conn
1216-
unless hasSentClose $ WS.send conn msg
1217-
writeIORef (connData c) Nothing
1218-
cleanConnectionData c
1219-
empty
1220-
1221-
NWS.Pong _ -> do
1222-
TOD t _ <- liftIO getClockTime
1223-
liftIO $ modifyMVar_ (isBlocked c) $ const $ Just <$> return t
1224-
receiveData' c conn
1225-
--NWS.connectionOnPong (WS.connectionOptions conn)
1226-
--NWS.receiveDataMessage conn
1227-
NWS.Ping pl -> do
1228-
TOD t _ <- liftIO getClockTime
1229-
liftIO $ modifyMVar_ (isBlocked c) $ const $ Just <$> return t
1230-
WS.send conn (NWS.ControlMessage (NWS.Pong pl))
1231-
receiveData' c conn
1232-
--WS.receiveDataMessage conn
1206+
-- perform timeouts and cleanup of the server when connections
1207+
1208+
receiveData' a b= NWS.receiveData b
1209+
-- receiveData' :: Connection -> NWS.Connection -> IO BS.ByteString
1210+
-- receiveData' c conn = do
1211+
-- msg <- WS.receive conn
1212+
-- tr ("RECEIVED",msg)
1213+
-- case msg of
1214+
-- NWS.DataMessage _ _ _ am -> return $ NWS.fromDataMessage am
1215+
-- NWS.ControlMessage cm -> case cm of
1216+
-- NWS.Close i closeMsg -> do
1217+
-- hasSentClose <- readIORef $ WS.connectionSentClose conn
1218+
-- unless hasSentClose $ WS.send conn msg
1219+
-- writeIORef (connData c) Nothing
1220+
-- cleanConnectionData c
1221+
-- empty
1222+
1223+
-- NWS.Pong _ -> do
1224+
-- TOD t _ <- liftIO getClockTime
1225+
-- liftIO $ modifyMVar_ (isBlocked c) $ const $ Just <$> return t
1226+
-- receiveData' c conn
1227+
-- --NWS.connectionOnPong (WS.connectionOptions conn)
1228+
-- --NWS.receiveDataMessage conn
1229+
-- NWS.Ping pl -> do
1230+
-- TOD t _ <- liftIO getClockTime
1231+
-- liftIO $ modifyMVar_ (isBlocked c) $ const $ Just <$> return t
1232+
-- WS.send conn (NWS.ControlMessage (NWS.Pong pl))
1233+
-- receiveData' c conn
1234+
1235+
1236+
-- --WS.receiveDataMessage conn
12331237
{-
12341238
mread (Connection _ _ _ (Just (Node2Node _ _ _)) _ _ _ _ _ _ _) = parallelReadHandler -- !> "mread"
12351239
@@ -3215,7 +3219,7 @@ dechunk= do
32153219

32163220
foldNet :: Loggable a => (Cloud a -> Cloud a -> Cloud a) -> Cloud a -> Cloud a -> Cloud a
32173221
foldNet op init action = atServer $ do
3218-
ref <- onAll $ liftIO $ newIORef Nothing -- eliminate additional results doe to unneded parallelism when using (<|>)
3222+
ref <- onAll $ liftIO $ newIORef Nothing -- eliminate additional results due to unneded parallelism when using (<|>)
32193223
r <- exploreNetExclude []
32203224
v <-localIO $ atomicModifyIORef ref $ \v -> (Just r, v)
32213225
case v of

0 commit comments

Comments
 (0)