Skip to content

Instantly share code, notes, and snippets.

😊
Me

Alexander Granin graninas

😊
Me
Block or report user

Report or block graninas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@graninas
graninas / recording.json
Last active Aug 17, 2019
Recording Sample
View recording.json
{
"entries": [
[
0,
{
"tag": "Normal"
},
"GenerateGUIDEntry",
"{\"contents\":{\"guid\":\"662ed4a1-950b-48cd-a91d-1091342070d9\"},\"tag\":\"GenerateGUIDEntry\"}"
],
View graninas_id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDecJ7pnlH12W8XFJ4nGl7tZomX6esTqrzAZoTLs6ZRn8baYOKwWf57w6uSts4x0xMfVrO5YZtlBA6YSA7ysqiVLkvjCGoWbUw5goJi3kCUnQewuBy0ukobz6i/ZIEJ8vxejNggmRkQnyitBCd7nnvaCWgwDonJj4W1r77xarWvtz3QjjpGMG59i+xjuQ3Fi7sqRmwgQmBcWyo2cerA3aU4BbhmDS6tSHO2gH7I7VmII3mZX+p+0ITBGyfLgCYI85/qugR9rgK79lwEYrAuLkzxj8FArrLQWtgqfshriZRT1lBabh6dX9PWN+ArNseZVgKeycUngKclANYbl3HVfglZ
@graninas
graninas / cpp_constexpr_fp.md
Last active Jan 26, 2019
C++ constexpr functional programming
View cpp_constexpr_fp.md
#include <iostream>

constexpr int sum (int a, int b)
{
	return a + b;
}

constexpr int ediv (int a, int b)
{
@graninas
graninas / cpp_fp_limitations.md
Last active Jan 25, 2019
C++ FP Limitations
View cpp_fp_limitations.md

Weak type deduction

auto, lambdas -> std::function

auto m1 = newTVar(10);                                                // ok
auto m2 = stm::bind<TVarInt, TVarInt>(m1, [](const auto& tvar)        // ok, full bind type specified
{
    auto mm1 = writeTVar(tvar, 20);
    return sequence(mm1, pure(tvar));
@graninas
graninas / cpp_stm_free_tutorial.md
Last active Nov 7, 2019
Software Transactional Memory in C++: Pure Functional Approach (tutorial)
View cpp_stm_free_tutorial.md

Software Transactional Memory in C++: pure functional approach (Tutorial)

In this article I’ll tell you about my pure functional library for Software Transactional Memory (STM) that I’ve built in C++. I adopted some advanced functional programming concepts that make it composable and convenient to use. Its implementation is rather small and robust, which differentiates the library from competitors. Let’s discuss what STM is and how to use it.

@graninas
graninas / STMSample.hs
Created Oct 19, 2017
Dining philosophers and STM
View STMSample.hs
takeFork :: TVar Fork -> STM ()
takeFork tvFork = do
fork <- readTVar tvFork
case fork of
InUse -> retry
Free -> writeTVar tvFork InUse
makeDiningPhilosopher :: TVar Fork -> TVar Fork -> STM (TVar Philosopher)
makeDiningPhilosopher leftFork rightFork = do
takeFork leftFork
You can’t perform that action at this time.