MFlow  Create and maintain dynamic Web applications as easy and fast as console applications
Thou shall not write request handlers
 This release: 11/06/2014.  agocorona@gmail.com (@agocorona) <>< . issues & bugs .  Mflow Source code,     source code of this site




World's longest working applicative and monadic combinator's expression ever


This is the expression for the main menu on the left. Probably it is the longest meaningful expression made in haskell ever using applicative and monadic combinators. It defines a cascade menu. It is located in Menu.hs.

The first entries of the menu on the lef are in an editable field tFieldEd and are stored in a static file called "othermenu" . The rest of the options are in a two-level cascade menu. To understand how it works, press:
Each branch is autoRefresh'ed using Ajax:

data Options= Wiki | CountI | CountS | Radio
            | Login | TextEdit |Grid | Autocomp | AutocompList
            | ListEdit |Shop | Action | Ajax | Select
            | CheckBoxes | PreventBack | Multicounter
            | Combination | ShopCart | MCounter | InitialConfig | SearchCart
            | FViewMonad | Counter | WDialog |Push |PushDec |Trace | RESTNav
            | Database | MFlowPersist | AcidState
            | DatabaseSamples |PushSamples | ErrorTraces | Flows
            | BasicWidgets | MonadicWidgets | DynamicWidgets | LoginLogout
            | Templates | RuntimeTemplates | LoginWidget
            deriving (Bounded, Enum,Read, Show,Typeable)

absLink ref = wcached (show ref) 0 . wlink ref

mainMenu :: View Html IO Options
mainMenu=
  ul<<<(li << a ! href "/" ! At.class_ "_noAutoRefresh" << b "HOME"
   ++> tFieldEd "editor" "othermenu" "Other menu options"
   **> (li <<< ((absLink Wiki << b "Wiki") <! [("class", "_noAutoRefresh")]))
   <|> li << (b "About this menu" <> article cascade <> article menuarticle)
   ++> hr
   ++> ((autoRefresh $ li <<< do
          absLink BasicWidgets << b "Basic Widgets"
          ul <<<
           (hr
           ++> (li <<< (absLink CountI << b "Increase an Int") <! noAutoRefresh
                       <++ b " A loop that increases the Int value of a text box"
                                   
           <|> li <<< (absLink CountS << b "Increase a String") <! noAutoRefresh
                       <++ b " A loop that concatenate text in a text box"
                                   
           <|> li <<< (absLink Select << b "Select options") <! noAutoRefresh
                       <++ b " A combo box"
                                   
           <|> li <<< (absLink CheckBoxes << b "Checkboxes") <! noAutoRefresh
           
           <|> li <<< (absLink Radio << b "Radio buttons") <! noAutoRefresh
           <++ hr)))

    <|> (autoRefresh $ li <<< do
          absLink DynamicWidgets << b "Dynamic Widgets"
             <++ " Widgets with Ajax and containers of other widgets"
          ul <<<
           (hr
           ++>(li <<< (absLink Ajax << b "AJAX example") <! noAutoRefresh
                 <++ b " A onclick event in a text box invokes a server procedure that \
\increment the integer value"
                 <> article ajaxl

           <|> li <<< (absLink Autocomp << b "autocomplete") <! noAutoRefresh
                 <++ b " Example of autocomplete, a widget which takes the suggested values from a \
\ server procedure"

           <|> li <<< (absLink AutocompList << b "autocomplete List") <! noAutoRefresh
                 <++ b " Example of a widget that generates a set of return values, suggested by a \
\ autocomplete input box"
                 <> article editList

           <|> li <<< (absLink ListEdit << b "list edition") <! noAutoRefresh
                 <++ b " Example of a widget that edit, update and delete a list of user-defined \
\ widgets"

           <|> li <<< (absLink Grid << b "grid") <! noAutoRefresh
                 <++ b " Example of the same widget In this case, containing a row of two fields,\
\ aranged in a table"
                 <> article gridl
           <> hr)))

    <|> (autoRefresh $ li <<< do
          absLink MonadicWidgets << b "Monadic widgets, actions and callbacks"
             <++ " autoRefresh, page flows, dialogs etc"
          ul <<<
            (hr
            ++>(li <<< (absLink Action << b "Example of action") <! noAutoRefresh
                <++ " executed when a widget is validated"

            <|> li <<< (absLink FViewMonad << b "in page flow: sum of three numbers") <! noAutoRefresh
                 <++ b " Page flows are monadic widgets that modifies themselves in the page"
                 <> article pageflow

            <|> li <<< (absLink Counter << b "Counter") <! noAutoRefresh
                 <++ b " A page flow which increases a counter by using a callback"
                 <> article callbacks

            <|> li <<< (absLink Multicounter << b "Multicounter") <! noAutoRefresh
                 <++ b " Page flow with many independent counters with autoRefresh, so they modify themselves in-place"
                 <> article callbacks

            <|> li <<< (absLink Combination << b "Combination of three dynamic widgets") <! noAutoRefresh
                 <++ b " Combination of autoRefreshe'd widgets in the same page, with\
\ different behaviours"
                 <> article combinationl

            <|> li <<< (absLink WDialog << b "Modal dialog") <! noAutoRefresh
                 <++ b " A modal Dialog box with a form within a page flow"
            <> hr)))

   <|> (autoRefresh $ li <<< do
          absLink DatabaseSamples << b "Database examples"
             <++ " with different backends"
          ul <<<
           (hr
           ++>(li <<< (absLink SearchCart << b "Shopping with data tier, queries and full text search") <! noAutoRefresh
                <++ b " The shopping example completed with a dynamic catalog stored using TCache"
                <> article searchcart

           <|> li <<< (absLink MFlowPersist << b "Persistent") <! noAutoRefresh
                     <++ do -- blaze-html monad
                        b " illustrates the use of MFlow with "
                        a "Persistent" ! href yesodweb
                        " (In this example sqlite backend is used) "
                        article persistentarticle

           <|> li <<< (absLink Database << b "Database") <! noAutoRefresh
                     <++ b " Create, Store and retrieve lines of text from Amazon SimpleDB \
\ storage "
                     <> article amazonarticle
           <|> li <<< (absLink AcidState << b "Acid State") <! noAutoRefresh
                     <++ do -- blaze-html monad
                        b " Create, Store and retrieve lines of text from "
                        a ! href "http://hackage.haskell.org/package/acid-state" $ "Acid State"
                        hr)))

   <|> (autoRefresh $ li <<< do
          absLink PushSamples << b "Push Samples"
             <++ " using long polling"
          ul <<<
           (hr
           ++>(li <<< (absLink Push << b "Push example") <! noAutoRefresh
                     <++ b " A push widget in append mode receives input from \
\a text box with autorefresh"
                     <> article pushl
                     
           <|> li <<< (absLink PushDec << b "A push counter") <! noAutoRefresh
                     <++ b " Show a countdown. Then goes to the main menu"
                     <> article pushdec
                     <> hr)))

   <|> (autoRefresh $ li <<< do
          absLink ErrorTraces << b "Error Traces"
          ul <<<
            (hr
            ++>(li <<< (absLink Trace << b " Execution traces for errors") <! noAutoRefresh
                 <++ b " produces an error and show the complete execution trace"
                 <> article errorTrace
                 <> hr)))
                 
   <|> (autoRefresh $ li <<< do
          absLink Flows << b "Different kinds of flows"
          ul <<<
           (hr
           ++>(li <<< (absLink RESTNav << b " REST navigation") <! noAutoRefresh
                <++ b " Navigates trough menus and a sucession of GET pages"
                <> article navigation


           <|> li <<< (absLink ShopCart << b "Stateful persistent flow: shopping") <! noAutoRefresh
                <++ b " Add articles to a persistent shopping cart stored in the session log."
                <> i " getSessionData is read in the View monad to get the most recent shopping cart\
\even when the back button has been pressed"
                <> article stateful

           <|> li <<< (absLink SearchCart << b "Shopping with data tier, queries and full text search") <! noAutoRefresh
                <++ b " The shopping example completed with a dynamic catalog stored using TCache"
                <> article searchcart

           <|> li <<< (absLink MCounter << b "Persistent stateful flow: Counter") <! noAutoRefresh
                <++ b " a persistent counter. It uses the same mechanism than shopping, but it is\
\a more simple example"

           <|> li <<< (absLink PreventBack << b "Prevent going back after a transaction") <! noAutoRefresh
                 <++ b " Control backtracking to avoid navigating back to undo something that can not be undone\
\. For example, a payment"
                 <> article preventbackl

           <|> li <<< (absLink InitialConfig $ b "Initial Configuration in session parameters") <! noAutoRefresh
                 <++ b " the user is asked for some questions initially that never will be asked again \
\ unless he likes to change them (all in session parameters)"

                 <> hr)))

  
   <|> (autoRefresh $ li <<< do
          absLink Templates << b "Runtime templates"
             <++ " Templates and content management modifiable at runtime"
          ul <<<
           (hr
           ++>(li <<<(absLink RuntimeTemplates << b "Runtime templates") <! noAutoRefresh
                 <++ b " Example of form templates and result templates modified at runtime"
           <|> li <<< (absLink TextEdit << b "Content Management") <! noAutoRefresh
                 <++ b " Example of content management primitives defined in MFlow.Forms.Widgets"
                 <>hr)))

   <|> (autoRefresh $ li <<< do
          absLink LoginLogout << b "Login/logout"
          ul <<<(hr ++> (li <<< (absLink Login << b "login/logout") <! noAutoRefresh
                            <++ b " Example of using the login and/or logout"
                            <> hr)))

       )


comments powered by Disqus