Browse Source

version change, stack commit change

addedsingle
Alberto G. Corona 5 years ago
parent
commit
cb5f2f6ee0
  1. 4
      src/Transient/Move.hs
  2. 2
      stack.yaml
  3. 124
      tests/cell.hs
  4. 2
      transient-universe.cabal

4
src/Transient/Move.hs

@ -512,7 +512,9 @@ teleport = do
--set his own closure in his Node data
let closLocal = sum $ map (\x-> case x of Wait-> 1000; _ -> 1) fulLog
let closLocal = sum $ map (\x-> case x of Wait -> 100000;
Exec -> 1000
_ -> 1) fulLog
-- closLocal <- liftIO $ randomRIO (0,1000000)
liftIO $ modifyMVar_ closures $ \map -> return $ M.insert closLocal (fulLog,cont) map

2
stack.yaml

@ -3,7 +3,7 @@ packages:
- '.'
- location:
git: https://github.com/agocorona/transient.git
commit: 53f8d775055934c87fdf0f56602c17369b0d8233
commit: 8d44c8fee7ad10e76385dc68898af09c55819846
extra-dep: true
extra-package-dbs: []
flags: {}

124
tests/cell.hs

@ -1,121 +1,39 @@
{-# LANGUAGE OverloadedStrings #-}
import Transient.Base
import Transient.Move
import Transient.Internals((!>))
import Transient.Move.Utils
import GHCJS.HPlay.Cell
import qualified GHCJS.Perch as P (input)
import GHCJS.HPlay.View hiding (option, input)
import GHCJS.HPlay.View
import Control.Monad.IO.Class
import Data.String
import System.Random
import Data.List
import Data.IORef
import System.IO.Unsafe
import Control.Concurrent(threadDelay)
main= keep $ initNode $ onBrowser $ local $ render $ do
mk cellA (Just 1) <|> mk cellB (Just 2)
calc
where
cellA = scell "cella" $ runCloud $ do
lliftIO $ print "local"
atRemote $ local $ do
v <- norender $ gcell "cellb"
liftIO $ print "running cella at server"
return $ 2 * v
cellB = scell "cellb" $ runCloud $ do
lliftIO $ print "local2"
atRemote $ local $ do
v <- norender $ gcell "cella"
liftIO $ print "running cellb at server"
return $ 4 * v
main2= keep $ initNode $ onBrowser $ do
local $ render $ rawHtml $ h1 ("laps" :: String)
import Control.Monad
lap <- atRemote laps <|> return 0
lap' <- local $ render $ inputInt (Just lap) `fire` OnKeyUp <|> return lap
-- ++> adds rendering to a widget
carPositions lap'
main= keep $ initNode $ inputNodes <|> app
app= onBrowser $ local $ render $ do
mk space (Just 1) ! size "10" <|> br ++>
mk time (Just 2) ! size "10" <|> br ++>
mk speed (Just 3) ! size "10"
where
carPositions l = do
pos <- atRemote $ carPosition l
local $ render $ rawHtml $ p pos
carPosition lap= local $ do
positions <- liftIO $ readIORef rposList !> ("carpositions", lap)
if lap >= length positions !> ("length", length positions)
then empty
else return $ positions !! lap
-- distance= mkscell "distance" (Just 0) (gcell "lap" * 15) ! size "5"
rposList= unsafePerformIO $ newIORef [] :: IORef [[String]]
calc
where
size= atr "size"
laps= local $ do
r<- parallel $ do
threadDelay 10000000
newpos <- carPos
positions <- readIORef rposList !> newpos
writeIORef rposList $ positions ++ [newpos]
let l= length positions
return $ if l == totalLaps
then SLast $ fromIntegral l
else SMore $ fromIntegral l
case r of
SLast lap -> empty
SMore lap -> return lap
space = scell "space" $ runCloud $ atRemote $ local $ do
liftIO $ print "running cella at server"
norender $ gcell "speed" * gcell "time"
where
carPos= do
pos <- randomRIO (0,2)
let carpos= cars !! pos
return $ carpos : (cars \\ [carpos])
time = scell "time" $ runCloud $ atRemote $ local $ do
liftIO $ print "running cellb at server"
norender $ gcell "space" / gcell "speed"
totalLaps= 42
cars =["car1", "car2", "car3"]
speed = scell "speed" $ runCloud $ atRemote $ local $ do
liftIO $ print "running cellc at server"
norender $ gcell "space" / gcell "time"
size= atr "size"
fs= fromString
-- rawHtml $ h1 $ ("calculate space, time and speed " :: String)
--
-- wprint ("Can change one of the cell and the other two will be recalculated"::String)
--
-- (pre <<< ("a car runs for" ++> space
-- **> " Kms during" ++> time **> " Hours;\n"
-- ++> "His mean speed was" ++> speed <++ "Km/h\n"))
--
-- **> (P.input ! atr "type" "submit" ! atr "value" "calc" `pass` OnClick)
--
-- liftIO $ alert "calc"
--
-- calc
--
-- where
-- space= mkscell "space" (Just 1) (gcell "speed" * gcell "time") ! size "5"
-- time = mkscell "time" (Just 1) (gcell "space" / gcell "speed") ! size "5"
-- speed= mkscell "speed" (Just 1) (gcell "space" / gcell "time") ! size "5"
getPort :: TransIO Integer
getPort =
if isBrowserInstance then return 0 else do
oneThread $ option "start" "re/start" :: TransIO String
port <- input (const True) "port to listen? "
liftIO $ putStrLn "node started"
return port

2
transient-universe.cabal

@ -1,5 +1,5 @@
name: transient-universe
version: 0.3.2.4
version: 0.3.3
cabal-version: >=1.10
build-type: Simple
license: MIT

Loading…
Cancel
Save