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
C:\Users\magocoal\OneDrive\Haskell\devel\tryhplay>git push heroku master
Initializing repository, done.
Total 0 (delta 0), reused 0 (delta 0)
-----> Fetching custom git buildpack... done
-----> Haskell app detected
-----> Deploying with Haskell on Heroku
BUILDPACK_URL: http://github.com/mietek/haskel
l-on-heroku

In haskell, continuations have been right in front of your eyes all the time, Use then to undo actions by means of the backtracking effect added to the the hardworking programmer EDSL.

#A word on continuations# In Haskell, the continuation is the second parameter in the bind operation. While most languages that use imperative and eager execution have to resort to continuations to implement special kinds of flows -so the continuation play a central role in them- haskell has not such problem: It uses continuations natively; The monad instance define what each kind of computation has to do with these continuations.

a bind has two parameters: a closure and a continuation.

 x >>=(f1>>=(f2 >>=f3))

So at every moment you know what is the continuation. In any monad. You don't need any special Cont structure for this!!!. It is right there, in the monad instance:

@agocorona
agocorona / gist:caf924d931c5d0406022
Last active August 29, 2015 14:18
A special form with some tricks in hplayground . compile it with http://tryplayg.herokuapp.com/
import Haste.HPlay.View
import Prelude hiding (div)
main= runBody $ do
let id= atr "id"
type_= atr "type"
name= atr "name"
value= atr "value"
r <-div ! id "selectors" <<<(
( button "Form A" `pass` OnClick >> return True) <|>
#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
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
@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"
@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 / cordova.hs
Last active September 25, 2015 16:31
--
-- Hello-World of the cordova/phonegap application using Haskell.
--
-- here is the screenshoot
--
-- https://twitter.com/AGoCorona/status/532948528621178880
--
-- So that Haste-Haskell can be used to create hybrid smartphone applications
--
-- The original cordova JavaScript hello world is installed following the instructions of this page
@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 / 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