# Introduction This tutorial shows some examples of the use of [MFlow](http://hackage.haskell.org/package/MFlow) as a DSL for web applications rather than as a web framework as such made of heterogeneous stuff. This tutorial modify step by step a simple application, the canonical application of stateful web frameworks, that ask for two numbers and show the result. This initial application is modified with different applicative and monadic combinators to create from a multipage application to a single page application, AJAX driven, with autorefresh, push, runtime templating and so on. The same code can be combined to create very different kinds of applications under the same paradigm. MFlow is essentially a set of applicative and monadic combinators that implement tracking and backtracking effects for navigation, logging for state persistence and an extension of formlets for the user interface. This set of examples do not exhaust the variety of use cases that the model solves. For, example, route descriptions as monadic expressions can be seen in this more basic [MFlow Introduction](https://www.fpcomplete.com/user/agocorona/MFlow-tutoria). For more complex examples see the [MFlow demos site](http://mflowdemo.herokuapp.com) *NOTE: SOH seems to run a single web snippet per user and session. It takes certain time until it reset itself. Otherwise, a previous executed example will stay running instead of the one you are expecting.* *NOTE2: Since the SOH uses HTTPS, the browser reject the load of third party scripts, such is JQuery, so look at the notes of each example.* ## The initial example: Sum application with three pages Two pages ask for a number. The third shows the result and a link. Yet, the code(almost) fit in a tweet. If the link is pressed, the first page appears again, since `runNavigation` runs the navigation in a loop. The back button works. ``` haskell active web {-# LANGUAGE OverloadedStrings #-} import MFlow.Wai.Blaze.Html.All main= runNavigation "" . step $ do n <- page $ getInt Nothing <** submitButton "first" n' <- page $ getInt Nothing <** submitButton "second" page $ p << ( n+n') ++> wlink () "click" ``` Note that although `getInt` is a form field that expect an Int, the `