Thursday, May 23, 2013

Running MFlow applications on Heroku

Updated: see my comments below.

After signing up in heroku and downloaded the heroku command line tools and the git tools,  you must have your application in a local git repository  and your command shell must be located where the .git directory is. Your application must have a cabal file,  and the file called ProcFile must contain the following:

> cat ProcFile

web  ./dist/build/path-to-the-executable-generated-by-cabal

Then create the heroku instance name and push it to heroku with these two commands, using anvil:

Don´t do it under Windows. It does not work!! Don´t spend a month trying it like me thinking that I am stupid!. Anvil currently does not work in Windows.

>heroku create myinstancename

>heroku plugins:install

>heroku build -r -b

Wednesday, May 01, 2013

A web application in a tweet

Playing yesterday to send a tweet about the previous post, I managed to put an application in a tweet:

Here below there is a complete application with three pages. In a loop, it ask for two numbers (it show two times a form with a text field asking for a number) . The third page show the sum and a link to  asking the next pair of numbers (The flow will restart again when it finish).

You can press the back button as you please. For example when you see the sum, you can press back one time, fill another number and see the sum of the first number with this new second number. The state is automatically synchronized with the navigation:

import MFlow.Wai.Blaze.Html.All

main= runNavigation "sum" . step $ do
       n1 <- get
       n2 <- get
       ask $ p << (n1+n2) ++> wlink () "click"
  get= ask $ getInt Nothing

And the tweet:

See the previous post for the same example not soo terse, with a few more things.