function workflow log

Alberto Gómez Corona 2012-09-22 23:21:08.173832 UTC

1{-# OPTIONS -XDeriveDataTypeable #-}
2module Main where
3
4import Data.Typeable
5import MFlow.Wai.XHtml.All
6import Control.Concurrent
7
8main= do
9 addMessageFlows [("",runFlow ops)]
10 forkIO $ run 80 waiMessageFlow
11 adminLoop
12
13ops= do
14 i <- ask $ p << ("Enter a number. This number will be the paramter for a function\n"
15 ++ "that will be defined by menu if it has not been defined previously")
16 ++> getInt Nothing
17
18 f <- runFlowIn "fun" getf
19
20 ask $ p << ("The result is: " ++ show (f i)) ++> wlink () (bold << "next")
21 ops
22 where
23 getf = do
24 op <- step . ask $ p << "let define the function: which operation?"
25 ++> getSelect(
26 setOption Plus (bold << "+") <|>
27 setOption Times (bold << "*"))
28 <** submitButton "submit"
29 num <- step . ask $ p << "give me another number" ++> getInt Nothing
30
31 return $ case op of
32 Plus -> (+ num)
33 Times -> (* num)
34
35data Ops= Plus | Times deriving (Read, Show, Typeable)