8 view label value :== viewInformation label [] value
9 edit label value :== updateInformation label [] value
10 fill label :== enterInformation label []
12 share label value :== sharedStore label value
13 watch label store :== viewSharedInformation label [] store
17 // (>>+) :: Task a -> List ( a -> Bool, a -> Task b ) -> Task b
19 (>>+) task options :== task >>* map trans options
21 trans ( p, t ) = OnValue (ifValue p t)
23 // (>>-) :: Task a -> (a -> Task b) -> Task b
25 (>>-) task cont = task >>+ [ ( ok, cont ) ]
27 // (>>|) :: Task a -> Task b -> Task b
29 (>>|) task next = task >>- \_ -> next
31 // (>>?) :: Task a -> List ( String, a -> Bool, a -> Task b ) -> Task b
33 (>>?) task options :== task >>* map trans options
35 trans ( a, p, t ) = OnAction (Action a) (ifValue p t)
38 // Data ////////////////////////////////////////////////////////////////////////
40 :: Seat = Seat Row Pos
45 { first_name :: String
51 { passengers :: List Person
57 // Stores //////////////////////////////////////////////////////////////////////
59 free_seat_store :: Shared (List Seat)
60 free_seat_store = share "Free seats" [ Seat r p \\ r <- [1..6], p <- ['A'..'D'] ]
63 // Checks //////////////////////////////////////////////////////////////////////
65 // Tasks ///////////////////////////////////////////////////////////////////////
67 removeElems :: (List a) (List a) -> List a | iTask a
70 // [ y \\ y <- ys, x <- xs | y =!= x ]
71 // filter (\x -> not (elem x ys)) ys
73 choose_seats :: Int -> Task (List Seat)
75 enterMultipleChoiceWithShared "Pick a seat" [] free_seat_store >>?
77 , \seats -> True//length seats == n
78 , \seats -> upd (removeElems seats) free_seat_store >>| return seats
82 main :: Task (List Seat)
84 (forever (watch "Free seats" free_seat_store >>* [OnAction (Action "Refresh") (always (treturn ()))]))
86 (choose_seats 2 >>- view "Chosen seats")
89 // Boilerplate /////////////////////////////////////////////////////////////////
91 derive class iTask Seat, Person, Booking
93 Start :: *World -> *World
94 Start world = startEngine main world