Skip to content

Instantly share code, notes, and snippets.

View agocorona's full-sized avatar
💭
Status at .... https://gitter.im/Transient-Transient-Universe-HPlay/Lobby

Alberto agocorona

💭
Status at .... https://gitter.im/Transient-Transient-Universe-HPlay/Lobby
View GitHub Profile
@agocorona
agocorona / composinguncomposable.md
Last active September 7, 2024 07:42
Composing the uncomposable

This is a serie of reflections on the presentation of Runar Branson Specifically, in the 39:30 he mention side effects as one of the main causes of the lack of composability. Most of the time we need the effects arranged in a different way than the one that forces the composition. For the example that he mentions: choose coffe, pay, serve, we can sustitute the one whose effect we want to reorder (pay) by one non-effectful, (add-to-cart) so that we can make many selections and pay at the end. What we do is to keep in the cart state the items selected.

But there are other reasons why side effects can prevent composition: threading, blocking for wathever reasons: communications, semaphores, callbacks, concurrency, loops waiting for some conditions... These are considered as lost cases for composition and not even mentioned. But transient demonstrates that this is not the case, that it is possible t

@agocorona
agocorona / move.md
Last active October 24, 2022 22:19
Managing Haskell computations as data for storage, restore, translate and distributed computing

Managing Haskell computations as data for storage, restore, translate and distributed computing

This is a tutorial about how to handle the complete state of a computation so that it can be serialized, stored, translated, analyzed, restored his execution etc

This text summarizes my reseach with Transient in this aspect which is the least known. I want to make it public since I belive has useful contributions to real world computing problems in novel ways and may make a difference. The text is the result of a balance between didactic simplicity (my intention) and the terseness of my laziness.

I use a pseudocode similar to Haskell. This is a very first version which will have errors for sure. But it gives an idea. I will perfect the content from time to time to make it more informative. At first it will be a gist.

@agocorona
agocorona / transient-url.md
Last active August 21, 2020 23:12
HTTP interface for transient programs

This is a tutorial intended to teach how to invoke any part of a Transient-universe program using HTTP requests. It is also very useful to understand the mechanism of serialization and remote execution of distributed transient programs.

This is not the REST API that is also included in transient-universe. This API is shown in examples like api.hs which Is undocumented but I hope, may be self-explaining.

Note this is the api.hs version for the "new" branch which is being detailed here.

Transient is a library for the language Haskell that allows high-level effects like parallelism, concurrency, asynchronicity, streaming and distributed computing and manage them without special constructions.

@agocorona
agocorona / resources.md
Last active April 14, 2021 22:10
Asynchronous exceptions and de-inverted management of resources in transient

Asynchronous exceptions and management of resources in transient

NOTE: All this has been superseeded by finalizations

I was looking at the last article of Michael Snoyman about asynchronous exceptions. Proper handling of resources in long term programs such are servers demands very accurate management of resources. In transient where many threads are spawned and sometimes killed asynchronously, this is even more important.

So I first tried to create a version of bracket for the transient monad:

bracket
@agocorona
agocorona / Bench.hs
Created August 31, 2019 11:17
Benchmark for the transient monad compared with others
--Based on https://gist.github.com/gelisam/be8ff8004cd701a084b6d64204a28bb6
{-# LANGUAGE DataKinds, DeriveFunctor, FlexibleContexts, GADTs, LambdaCase, RankNTypes, ScopedTypeVariables, TypeApplications, TypeOperators #-}
module Main (main) where
import qualified TransientCont as T -- this file: https://gist.github.com/agocorona/2c9149c4d2035f21952fc1d1691b7bde
import Criterion (bench, bgroup, nf,whnfIO)
import Criterion.Main (defaultMain)
  • Do NOT use loops. Loops destroy composition. Use streaming/ non determinism (multithreaded or not):
forM [1..10]  $ \i -> ...   use:   i <- threads 0  $ choose [1..10]    
                                   -- run in the current thread
-- like for i = 1 to 10... 
  • Do NOT use callbacks. De-invert callbacks with react:
onCallback wathever mycallback    use:     event <- react (onCallback wathever) (return())         
-- first attempt (not compiled) of an example simulation of petri net https://twitter.com/semanticbeeng/status/1120662696985268225
-- assume that the input is stored by a process `receive` not detailed here which store the entries in two transactional variables
-- read from two typed channels A and B
-- return three responses of type C
import Control.Concurrent.STM.TVar
import Transient.Base