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
cb <- syncCallback1 ContinueAsync
(\r -> do
(x,y) <-fromJSValUnchecked r
stopPropagation r
print (x, y))
js_addEventListener elem "mousemove" cb
@agocorona
agocorona / IRCtransient.hs
Created July 12, 2016 09:37
Simple Haskell IRC client in "two lines of code"
import Transient.Base
import Network
import System.IO
import Control.Monad.IO.Class
import Control.Applicative
-- taken from Pipes example
-- https://www.reddit.com/r/haskell/comments/2jvc78/simple_haskell_irc_client_in_two_lines_of_code/?st=iqj5yxg1&sh=0cb8cc11
-- Simple Haskell IRC client in "two lines of code"
module Main where
import Lib
import Model
import GHCJS.HPlay.View hiding (input, option, pack)
import qualified GHCJS.Perch as P (input)
import Transient.Base
import Transient.Move
@agocorona
agocorona / fake.hs
Created February 9, 2016 16:52
fake perch-hplaygroud sample definitions
#ifndef ghcjs_HOST_OS
static= id
dynamic= id
strip= id
inputInt :: Maybe Int -> TransIO Int
inputInt _ = empty
inputSubmit :: String -> TransIO String
@agocorona
agocorona / error.txt
Last active November 6, 2015 14:06
A websockets program for ghcjs that fails with ghcjs 0.2.0 and ghcjs-base commit 23b1311
in chrome console:
JavaScript exception: ReferenceError: h$closeWebSocket is not defined
rts.js:9543 user error (If you can read this, shutdownHaskellAndExit did not exit.)
rts.js:9543 user error (If you can read this, shutdownHaskellAndExit did not exit.)
rts.js:9543 user error (If you can read this, shutdownHaskellAndExit did no
....
....
@agocorona
agocorona / streamtest.hs
Created September 17, 2015 09:27
test for send buffer overflow
module Main where
import Network
import Network.Socket hiding (listen, accept)
import System.IO
import Control.Concurrent
import Control.Monad
import Control.Monad.IO.Class
@agocorona
agocorona / login.mflow.hs
Last active September 8, 2015 12:23
login widget. present login/pass button
-- normally to be used with autoRefresh and pageFlow when used with other widgets.
authenticateWidget :: View Html IO ()
authenticateWidget= wform $ do
username <- getCurrentUser
if username /= anonymous
then do
private; noCache;noStore
return username -- if it is logged alredy, return username to the first wcallback
else do -- if not it tries to get the user/pass from the paramenters and log in if the user sent login/passw
(name, pass) <- (,) <$> (getString Nothing <! hint "login name"
module Main where
import MFlow.Wai.Blaze.Html.All hiding( page)
import qualified MFlow.Wai.Blaze.Html.All as MF(page)
main= runNavigation "" $ transientNav testNav
testNav= do

This article has been rewritten the 19/08/2015

Motivation (yours not mine)

The distributed framework that I´m developing is a completely different way to consider distributed computing in the same sense that Transient is a different way to program in Haskell or in any other language. It is so straighforward that is difficult to understand after decades of inversion of control, programming state machines objects framewors, routes and callbacks. If you dare to think different you will benefit from this higher level way of programming that I´m convinced that is the future.

It is the future because it is functionality oriented, not object oriented. A software functionality is a business process, that naturally compose with other business processes. A process is like physiology, while OOP is like anatomy. Functional programming is about composability, wether efectful or not. Transient is deeply functional and can express business functionalities in compact category theoretical expressions that compose, with

#Introduction
This tutorial:
- Will show how the development of web applications, workflows, asynchronous tasks, Enterprise Application Integration(EAI), Service Integration and Business Process Management (BPM) face the same underlying problem, that may be called the integration problem. That is, in essence, a problem of inversion of control.
- Will show how the traditional architecture that solves that problem, the state-transition system, end up in the creation of complex frameworks with excessive configurations, standards, APIs and development environments specialized for each particular problem that hides the commonalities and make the integration prohibitively expensive and difficult to program and maintain, while the language Haskell permits the implementation of a common underlying solution for all these problems that is vastly simpler and intuitive.
- For a practical problem, you will learn how to program and test a long running task (a workflow) in a monadic sequence that will automatica