-
Notifications
You must be signed in to change notification settings - Fork 12
/
SumView.hs
31 lines (25 loc) · 1.16 KB
/
SumView.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{-# OPTIONS -XCPP #-}
module SumView (sumInView) where
-- #define ALONE -- to execute it alone, uncomment this
#ifdef ALONE
import MFlow.Wai.Blaze.Html.All
main= runNavigation "" $ transientNav grid
#else
import MFlow.Wai.Blaze.Html.All hiding(retry, page)
import Menu
#endif
sumInView= page $ p << "ask for three numbers in the same page and display the result."
++> p << "It is possible to modify the inputs and the sum will reflect it"
++> sumWidget
sumWidget= pageFlow "sum" $ do
n <- do
n1 <- p << "Enter first number" ++> getInt Nothing <++ br
n2 <- p << "Enter second number" ++> getInt Nothing <++ br
n3 <- p << "Enter third number" ++> getInt Nothing <++ br
return (n1+ n2 + n3)
-- factoring out the button
<** br ++> pageFlow "button" (submitButton "submit")
p << ("The result is: "++show n) ++> wlink () << b << " menu"
<++ p << "you can change the numbers in the boxes to see how the result changes"
-- to run it alone, replace page by ask and uncomment the following line
--main= runNavigation "" $ transientNav sumWidget