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"
where
get= ask $ getInt Nothing
And the tweet:
Web app in a tweet: do{n1<-get; n2<-get; ask$p<<(n1+n2)++>wlink () "click"} where get= ask$ getInt Nothing #Haskell haskell-web.blogspot.com.es/2013/05/a-web-…
— Alberto G. Corona (@AGoCorona) May 1, 2013
See the previous post for the same example not soo terse, with a few more things.
No comments:
Post a Comment