19,215 questions
1
vote
2
answers
52
views
In the context of STM, what does a transaction log conceptually look like, and how does it evolve when the transaction succeeds after a few retries?
For instance consider this function, that could be used in a WM to allow moving a window from one desktop to another on a given display,
moveWindowSTM :: Display -> Window -> Desktop -> ...
3
votes
1
answer
49
views
How do let and case differ in terms of lazyness?
How do let and case differ in terms of lazyness? Where do I find the information myself? And how do I experiment with it in ghci?
Some context
This incomplete piece of code is an excerpt from
Parallel ...
0
votes
2
answers
34
views
How do I pass an updated object down to a Child Component in React?
I have this code where I've updated an object in React. When you click "Most upvoted", it takes an object, sorts it by votes, and then updates the state with it. The problem is, it won't ...
2
votes
1
answer
61
views
How can GHC's fairness guarantee not show up if a thread is descheduled while it is not holding the MVar?
In Parallel and Concurrent Programming in Haskell by Simon Marlow, chapter 7 starts at page 125 with this example,
import Control.Concurrent
import Control.Monad
import System.IO
main :: IO ()
main = ...
1
vote
2
answers
64
views
Clarification on the importance of the immutability of the state inside an MVar in the context of concurrency
In Parallel and Concurrent Programming in Haskell by Simon Marlow, at pages 133 and 134 the following code is shown:
type Name = String
type PhoneNumber = String
type PhoneBook = Map Name ...
2
votes
1
answer
98
views
Why should bracket's first argument perform at most one blocking operation?
In Parallel and Concurrent Programming in Haskell by Simon Marlow, the implementation of bracket is shown,
bracket
:: IO a -- ^ computation to run first (\"acquire resource\")...
3
votes
3
answers
104
views
Does throw behave the same as throwIO, if instantiated as IO a?
I'm reading Parallel and Concurrent Programming in Haskell by Simon Marlow, and I initially read this suggestion fairly lightly,
It is always better to use throwIO rather than throw in the IO monad ...
2
votes
1
answer
42
views
Lean 4: Agda user struggling to understand Lean's equality type, type mismatch, not reducing
I am quite comfortable with Agda. I decided to experiment with Lean, but I find that propositional equality is really messing with me. Sometimes I find that rfl just works, but at other times it doesn'...
2
votes
0
answers
101
views
Is it possible to create true sentinel values in Rust?
Say I have some simple struct, eg:
struct SomeStruct {
things: Vec<usize>
recent_thing: Option<usize>
}
I'm trying to assert some invariant on this struct. For example, maybe we want ...
3
votes
1
answer
59
views
Unresponsive ghci terminal [duplicate]
I read variables are immutable in haskell and something like the following does not work in haskell.
x = 30
x = x+1
But I still tried this to see what the compiler returns and I got the following :
...
2
votes
1
answer
59
views
Fixing a Haskell Generator's andAlso Function: Inconsistent Test Results
I'm working with a Haskell implementation of generators for a homework. I have an andAlso function that's supposed to add an additional predicate to a generator, but it's not working correctly in all ...
3
votes
2
answers
97
views
Immutability and side effects with dataflow TransformBlocks
I'm currently reading about TPL dataflow pipelines and there's something I'm curious about when it comes to TransformBlocks. As I understand it, TransformBlock<TInput, TOutput> accepts an input ...
1
vote
1
answer
73
views
Python's predicate composition
I would like to implement something similar to this OCaml in Python:
let example = fun v opt_n ->
let fltr = fun i -> i mod 2 = 0 in
let fltr = match opt_n with
| None -> ...
8
votes
4
answers
268
views
How to convert a std::optional to a std::expected?
I'm trying to convert a std::optional into a std::expected using a lambda function.
The code I have written does not compile. The compiler complains that the monadic functions of std::optional must ...
0
votes
0
answers
45
views
How can I pass variables to a procedurally generated global function in Lua?
I was recently trying to write event callback handlers for my UI system, and I've been having trouble accessing higher-scope variables from a procedurally generated global function.
Here's some sample ...