Questions tagged [tvar]
15 questions
14
votes
2 answers
Haskell code littered with TVar operations and functions taking many arguments: code smell?
I'm writing a MUD server in Haskell (MUD = Multi User Dungeon: basically, a multi-user text adventure/role-playing game). The game world data/state is represented in about 15 different IntMaps. My monad transformer stack looks like this: ReaderT…

the-konapie
- 601
- 3
- 10
13
votes
1 answer
Haskell: TVar: orElse
Is the "else" part of orElse called when a transaction is retried due to another transaction writing to a TVar it had read, or only when retry is explicitly called?

Clinton
- 22,361
- 15
- 67
- 163
9
votes
2 answers
Haskell: How does TVar work?
How does TVar work? From what I've read it attempts to run all transactions immediately upon receiving them, however, a transaction completing invalidates other currently running transactions, which must then restart. Is this how TVar works?
If this…

Clinton
- 22,361
- 15
- 67
- 163
7
votes
3 answers
Haskell: TVar: Preventing starvation
I'm considering using a TVar to store some state in a web application (that can be recreated on restart). However, the contention aspects of TVar concern me. It seems that a frequent short running transaction can starve out longer transactions by…

Clinton
- 22,361
- 15
- 67
- 163
5
votes
2 answers
Haskell: Updating two or more TVars atomically. Possible?
Can one transaction update two different TVars in an atomic way? i.e. can I compose data structures out of lots of TVars to reduce contention? If so, could you provide an example?

Clinton
- 22,361
- 15
- 67
- 163
3
votes
1 answer
Looking at the value of a TVar in GHCi
Working through Simon Peyton Jones concurrency example, I have the following code:
import Control.Concurrent.STM
import Control.Concurrent.STM.TVar
deposit account amount = do
bal <- readTVar account
writeTVar account (bal+amount)
I am…

zhon
- 1,610
- 1
- 22
- 31
2
votes
0 answers
Impulse response functions for Threshold VAR in R
I have two variables (a financial stress index "CISS" and output growth).
Using the tsDyn package in R, I first calculated the TVAR. paperis the time series consisting of CISS and the output growth.
tvarpaper = TVAR(paper, lag=2, nthresh=1,…

Heike
- 107
- 2
- 11
1
vote
1 answer
How to wait until forM_ finishes, when using TVar?
I'm writing a function, where I process a list using forM_, and append the result to a TVar list:
import Control.Concurrent.STM
import Control.Concurrent.STM.TVar
import Control.Concurrent (forkIO)
import Control.Monad (forM_)
insert :: a -> [a] ->…

Iter Ator
- 8,226
- 20
- 73
- 164
1
vote
2 answers
Haskell STM shard TVAR
I'm new to Haskell and STM and I'm trying to understand the basics concept.
In Haskell and Functional Programming in general,correct me if I'm wrong, there's no such thing like assignment.
I cannot write x=3; all I can do is generate an other…

user1544128
- 583
- 4
- 20
0
votes
0 answers
How to filter one dataframe column values using another dataframe column value?
Below is my Dataframe: Df1
origin 2001-01-01 00:00:00 2002-01-01 00:00:00 2003-01-01 00:00:00 ... 2009-01-01 00:00:00 2010-01-01 00:00:00 Grand Total
Simulation 1 2.281294e+13 NaN 1.459444e+20 ... …

Dark_Devil
- 1
- 3
0
votes
0 answers
R - How to deal with NA values in tvAR (tvReg) - Error: NAs in y
I am trying to run the following code:
##Chen et al (2017) TVC-HAR model
library(tvReg)
TVCHAR <- tvAR (MyData$Pct_change_plus_250, p = 1, exogen = cbind (MyData$Pct_change_250), bw = 20)
print(TVCHAR)
but due to the fact that there are some NA…

adrCoder
- 3,145
- 4
- 31
- 56
0
votes
1 answer
Multivariate time series - splitting after one variable for IRF
I have a threshold VAR. Since nonlinear irf's are not possible in R, I want to get my way around it with IRF's.
Following are the codes for my multivariate time series and then the…

Heike
- 107
- 2
- 11
0
votes
0 answers
R: length of 'dimnames' [2] not equal to array extent
I am trying to run a threshold autoregressive model in "r" with the tsDyn package.
I have run the following command in "r":
Tar <- TVAR(spread, lag=1, include = c("both"), model = ("TAR"), thDelay = 1, trim=0.1, mTh = 1, plot=TRUE)
and i get the…
0
votes
1 answer
Type error with the use of transactional memory
I am using Transaction variables in haskell that I instantiate in a function and collect in a list and that I give to another function to write values in:
step player ghosts info = do let unblocked = allPaths (source info) (target info) (graph…

JasperTack
- 4,337
- 5
- 27
- 39
-1
votes
1 answer
TVar constructor? I can't get a TVar
I'm new at Haskell and stm and I wanted to make a simple rwlock. First I created the 4 main functions (wlock, wunlock, rlock, runlock) that requires 2 TVar Integers: the amount of reading threads and writing threads.
At this point I can't use it as…

Pernoctador
- 108
- 8