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 / runpatterh.md
Created March 7, 2019 18:00
Run pattern considered harmful

A lot of problems in haskell development is related with the problem of chaining effects. How do I insert an effect in a chain of computations?

Since the chain operation is bind, and has this signature:

  (>>=) :: m a -> (a -> m b) -> m b

then the two operands: the result of the chain and the rest of the chain should be in the same monad, so they should have the same effects.

To overcome this problem the monad transformer and the free monad use the "runXXX" and the lift pattern with XXX being the effect desired can run for some time:

@agocorona
agocorona / erlang-transient.md
Last active March 3, 2019 18:59
Erlang versus transient distributed computing

I have been watching this interesting presentation of distributed computing in Erlang-elixir: https://www.youtube.com/watch?v=AiN4r8E9qKg

I want to mention the remarkable points and compare them with the transient way of distributed computing:

min 1:30 It defines a cookie as a command-line parameter. It is a good idea. Connections would be required to send the same cookie.

min 3:00 Erlang nodes connect all nodes with all by default and maintain a heartbeat between then, probably because the communication protocol is low level in order to be very fast. It uses UDP probably. Transient connect only on demand and a node may route request to other destination nodes. It is made for weakly coupled internet nodes rather than for a closed coupled local area network. For this reason transient uses TCP sockets and websockets. A node behind a firewall can be accessed using the HTTP port as long as websockets are enabled. Once connected the remote node can address nodes internal to the firewall trough the gateway

@agocorona
agocorona / ATM.hs
Last active January 5, 2024 02:42
Software for an ATM (a machine that dispenses cash or performs other banking services when an account holder inserts a bank card) . It includes server and Web program
#!/usr/bin/env execthirdlinedocker.sh
-- mkdir -p ./static && ghcjs -DDEBUG ${1} -o static/out && echo ${1} && runghc -DDEBUG ${1} ${2} ${3}
{-
Programmed following the requirements of a canonical Java project:
http://www.math-cs.gordon.edu/courses/cs211/ATMExample/
It demonstates that it is possible to program clearly at the level of the requirements so that the author of the requirements

Services are a standard feature of transient. a service is a transient program with a diferent codebase than the one of the calling program. the services are initiated stand alone or by the monitor service. Although they are transient haskell programs, they can execute internally wathever :they can do FFI or execute a shell. They can also be packaged into docker images.

monitorService:

-is an executable included in transient -it should run in each node of the cloud:

 monitorService -p start/thishost/3000 # first node 

Peer to Peer Cloud Computing

Current cloud services and traditional Web sites like Amazon or Azure or Google or Facebook all are centralized from the management point of view and thus, they suppose a threat as big as a Super-Mainframe would pose for privacy and security of the data as well as the computing power. Amazon could paralyze the entire world. Facebook can be perfect for political campaigns if the right "leaks" happens when they need them. we know it very well.

The source of concern are:

  • The centralized databases that consolidate all the data of all users instead of letting the user to control where to store his own data wether locally or in other's nodes and define his own access policies. Although centralized databases are also a consequence of other concerns depicted below, centralization of data is something desired, since it is very profitable for legal and -I´m worried- criminal uses of such data.

  • The methods for obtaining scalability apparently demand farms of computers, again

@agocorona
agocorona / stack trace
Created January 19, 2018 08:55
Eta MVar test
import Control.Monad
import Control.Applicative
import Control.Concurrent.MVar hiding (takeMVar, putMVar)
import qualified Control.Concurrent.MVar as MVar
import Control.Concurrent.Fiber
import Control.Concurrent.Fiber.MVar
import System.Environment
import GHC.Conc.Sync hiding (yield)
import GHC.Conc.IO
import Control.Monad.IO.Class
@agocorona
agocorona / Transient.cont.hs
Last active April 26, 2023 08:00
Optimized, simplified continuation monad that implement all the Transient effects (except Web, logging and distributed computing) with mock up implementation of some of them (https://github.com/transient-haskell/transient) Parallelism, concurrency, reactive, streaming, non-determinism, backtracking exceptions, state, early termination
{-# LANGUAGE MultiParamTypeClasses, ExistentialQuantification, ScopedTypeVariables, FlexibleInstances, FlexibleContexts, UndecidableInstances #-}
module TransientCont where
-- some imports
import Control.Applicative
import Control.Monad.IO.Class
import Control.Monad.Trans
-- hplayground by Alberto modified by mark mann
-- keeps score for up to nine players for many rounds
-- identify user and record round by round results
{-# LANGUAGE DeriveDataTypeable, FlexibleInstances, UndecidableInstances #-}
module Main where
import Haste
import Haste.Foreign
main= keep' $ do
r <- choose [1..10]
liftIO $ print r
no user package environment file found at /devel/transient
no user package environment file found at /devel/transient
Searching for eta in path.
Found eta at /root/.local/bin/eta
/root/.local/bin/eta --numeric-version
/root/.local/bin/eta is version 0.0.9.1
no user package environment file found at /devel/transient
Searching for eta-pkg in path.
Found eta-pkg at /root/.local/bin/eta-pkg
/root/.local/bin/eta-pkg --version