diff options
Diffstat (limited to 'assignment-13/uFPL')
-rw-r--r-- | assignment-13/uFPL/Sim.icl | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/assignment-13/uFPL/Sim.icl b/assignment-13/uFPL/Sim.icl index 0f232fc..7556867 100644 --- a/assignment-13/uFPL/Sim.icl +++ b/assignment-13/uFPL/Sim.icl @@ -288,10 +288,13 @@ where set (unlift (allShares rs)) ishares sim = - (updateSharedInformation (Title "Rules") [] irules - -&&- updateSharedInformation (Title "Shares") [] ishares + (updateSharedInformation (Title "Rules") + [UpdateUsing id (const id) (listEditor (Just $ const Nothing) True False Nothing gEditor{|*|})] irules + -&&- + updateSharedInformation (Title "Shares") + [UpdateUsing id (const id) (listEditor (Just $ const Nothing) True False Nothing gEditor{|*|})] ishares ) -&&- - (show -&&- check) + (check -&&- show) <<@ ArrangeHorizontal newShares :: [INamedRule] IShares -> Task IState @@ -356,14 +359,24 @@ where ifOk _ _ = Nothing buttonActions :: IShares -> [TaskCont String (Task String)] - buttonActions shrs = - [action ("Toggle B" <+ i) $ press i \\ i <- [0..5] | any ((==) ("b" <+ i) o isharedName) shrs] + buttonActions shrs = flatten + [ [ action ("Toggle B" <+ i) $ toggle i + , action ("Press B" <+ i) $ press i + ] \\ i <- [0..5] | any ((==) ("b" <+ i) o isharedName) shrs] where - press :: Int -> Task IState - press i = get istate >>= lift >>= \st -> case st of + toggle :: Int -> Task IState + toggle i = get istate >>= lift >>= \st -> case st of (st :: State) -> set (unlift {st & vars='M'.alter upd ("b" <+ i) st.vars}) istate with upd (Just s=:{val=v :: Bool}) = Just {s & val=dynamic not v, dirty=s.subscriptions} + press :: Int -> Task IState + press i = change True >>| step >>| change False + with + change v = get istate >>= lift >>= \st -> case st of + (st :: State) -> set (unlift {st & vars='M'.alter (upd v) ("b" <+ i) st.vars}) istate + + upd v (Just s) = Just {s & val=dynamic v, dirty=s.subscriptions} + millisActions :: IShares -> [TaskCont String (Task String)] millisActions shrs | any ((==) "millis" o isharedName) shrs = |