Commit 81874299 authored by Bas Lijnse's avatar Bas Lijnse Committed by Steffen Michels

Removed local state from interact result

parent c0582f88
......@@ -77,7 +77,7 @@ instance toString OSException
* Core interaction task. All other interaction tasks are derived from this
* one. `interactR` is almost identical but does not update the given sds.
*/
interactRW :: !(sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task (l,v) | iTask l & iTask r & iTask v & TC r & TC w & RWShared sds
interactRW :: !(sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task v | iTask l & iTask r & iTask v & TC r & TC w & RWShared sds
//* See documentation on `interactRW`.
interactR :: (sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task (l,v) | iTask l & iTask r & iTask v & TC r & TC w & Registrable sds
interactR :: (sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task v | iTask l & iTask r & iTask v & TC r & TC w & Registrable sds
......@@ -47,12 +47,12 @@ instance toString OSException
where
toString (OSException (_,err)) = "Error performing OS operation: " +++ err
interactRW :: !(sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task (l,v)
interactRW :: !(sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task v
| iTask l & iTask r & iTask v & TC r & TC w & RWShared sds
interactRW shared handlers editor
= Task (readRegisterCompletely shared NoValue (\event->mkUIIfReset event (asyncSDSLoaderUI Read)) (evalInteractInit shared handlers editor modifyCompletely))
interactR :: (sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task (l,v)
interactR :: (sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task v
| iTask l & iTask r & iTask v & TC r & TC w & Registrable sds
interactR shared handlers editor
= Task (readRegisterCompletely shared NoValue (\event->mkUIIfReset event (asyncSDSLoaderUI Read)) (evalInteractInit shared handlers editor \_ _->modifyCompletely (\()->undef) nullShare))
......@@ -78,17 +78,17 @@ evalInteract ::
(
(r -> w)
(sds () r w)
(TaskValue (l,v))
(TaskValue v)
(Event -> UIChange)
(w -> Event -> TaskEvalOpts -> *IWorld -> *(TaskResult (l,v),*IWorld))
(w -> Event -> TaskEvalOpts -> *IWorld -> *(TaskResult v,*IWorld))
Event
TaskEvalOpts
*IWorld
-> *(TaskResult (l,v),*IWorld))
-> *(TaskResult v,*IWorld))
Event
TaskEvalOpts
*IWorld
-> *(TaskResult (l,v),*IWorld)
-> *(TaskResult v,*IWorld)
| iTask l & iTask r & iTask v & TC r & TC w & Registrable sds
evalInteract _ _ _ _ _ _ _ _ DestroyEvent {TaskEvalOpts|taskId} iworld
= (DestroyedResult, 'SDS'.clearTaskSDSRegistrations ('DS'.singleton taskId) iworld)
......@@ -109,7 +109,7 @@ evalInteract l v mst mode sds handlers editor writefun event=:(EditEvent eTaskId
// Therefore we delay it by returning the continuation in a value instead of directly:
(\w event {TaskEvalOpts|lastEval} iworld->
(ValueResult
(Value (l, nv) False)
(Value nv False)
(mkTaskEvalInfo lastEval)
change
(Task (evalInteract l (Just nv) (Just st) mode sds handlers editor writefun))
......@@ -118,7 +118,7 @@ evalInteract l v mst mode sds handlers editor writefun event=:(EditEvent eTaskId
//There is no update function
Nothing
= (ValueResult
(Value (l, nv) False)
(Value nv False)
(mkTaskEvalInfo lastEval)
change
(Task (evalInteract l (Just nv) (Just st) mode sds handlers editor writefun))
......@@ -144,7 +144,7 @@ evalInteract l v mst mode sds handlers editor writefun ResetEvent evalOpts=:{tas
# mbv = editor.Editor.valueFromState st
# v = maybe v Just mbv
= (ValueResult
(maybe NoValue (\v->Value (l, v) False) v)
(maybe NoValue (\v->Value v False) v)
(mkTaskEvalInfo lastEval)
change
(Task (evalInteract l v (Just st) mode sds handlers editor writefun))
......@@ -153,7 +153,7 @@ evalInteract l v mst mode sds handlers editor writefun event=:(RefreshEvent task
| isNothing mst = (ExceptionResult (exception "corrupt editor state"), iworld)
# st = fromJust mst
| 'DS'.member taskId taskIds
= readRegisterCompletely sds (maybe NoValue (\v->Value (l, v) False) v) (\e->mkUIIfReset e (asyncSDSLoaderUI Read))
= readRegisterCompletely sds (maybe NoValue (\v->Value v False) v) (\e->mkUIIfReset e (asyncSDSLoaderUI Read))
(\r event evalOpts iworld
# (l, mbV, mbf) = handlers.InteractionHandlers.onRefresh r l v
# mbChange = case mbV of
......@@ -169,7 +169,7 @@ evalInteract l v mst mode sds handlers editor writefun event=:(RefreshEvent task
event evalOpts iworld
Nothing
= (ValueResult
(maybe NoValue (\v -> Value (l, v) False) v)
(maybe NoValue (\v -> Value v False) v)
(mkTaskEvalInfo lastEval)
change
(Task (evalInteract l v (Just st) mode sds handlers editor writefun))
......@@ -179,7 +179,7 @@ evalInteract l v mst mode sds handlers editor writefun event=:(RefreshEvent task
evalInteract l v mst mode sds handlers editor writefun event {lastEval} iworld
//An event for a sibling?
= (ValueResult
(maybe NoValue (\v->Value (l, v) False) v)
(maybe NoValue (\v->Value v False) v)
(mkTaskEvalInfo lastEval)
NoChange
(Task (evalInteract l v mst mode sds handlers editor writefun))
......
......@@ -95,7 +95,7 @@ findSelection target options idxs = target <$> getItems options idxs
enterInformation :: ![EnterOption m] -> Task m | iTask m
enterInformation options = enterInformation` (enterEditor options)
enterInformation` (EnterUsing fromf editor)
= interactRW unitShare handlers editor @ (\((),v) -> fromf v)
= interactRW unitShare handlers editor @ (\v -> fromf v)
where
handlers = {onInit = const ((), Enter), onEdit = \_ () -> ((), Nothing), onRefresh = \r () _ -> ((),undef,Nothing)}
......@@ -108,7 +108,7 @@ updateInformation :: ![UpdateOption m] m -> Task m | iTask m
updateInformation options m = updateInformation` (updateEditor options) m
updateInformation` (UpdateUsing tof fromf editor) m
= interactRW unitShare {onInit = const ((), Update $ tof m), onEdit = \_ l -> (l, Nothing), onRefresh = \r l v -> (l,v,Nothing)}
editor @ (\((),v) -> fromf m v)
editor @ (\v -> fromf m v)
updateSharedInformation :: ![UpdateSharedOption r w] !(sds () r w) -> Task r | iTask r & iTask w & RWShared sds
updateSharedInformation options sds = updateSharedInformation` (updateSharedEditor options) sds
......@@ -151,7 +151,7 @@ editSelection` attributes (SelectUsing toView fromView editor) container sel
{onInit = \r -> ((), Update (toView container,sel))
,onEdit = \_ () -> ((), Nothing)
,onRefresh = \_ () v -> ((),v,Nothing)
} (attributes @>> editor) @ (\(_,(_,sel)) -> fromView container sel)
} (attributes @>> editor) @ (\(_,sel) -> fromView container sel)
editSelectionWithShared :: ![SelectOption c a] (sds () c w) (c -> [Int]) -> Task [a] | iTask c & iTask a & TC w & RWShared sds
editSelectionWithShared options sharedContainer initSel = editSelectionWithShared` (selectAttributes options) (selectEditor options) sharedContainer initSel
......@@ -160,7 +160,7 @@ editSelectionWithShared` attributes (SelectUsing toView fromView editor) sharedC
{onInit = \r -> ((), Update(toView r, initSel r))
,onEdit = \_ () -> ((), Nothing)
,onRefresh = \r () v -> ((),(\(_, sel) -> (toView r,sel)) <$> v,Nothing)
} (attributes @>> editor) @ (\(_,(_,sel)) -> sel))
} (attributes @>> editor) @ (\(_,sel) -> sel))
-&&- watch sharedContainer //TEMPORARY: Don't use an extra task here
) @ (\(sel,container) -> fromView container sel)
) <<@ ApplyLayout unwrapUI
......@@ -172,7 +172,7 @@ editSharedSelection` attributes (SelectUsing toView fromView editor) container s
{onInit = \r -> ((), Update (toView container,r))
,onEdit = \(_,vs) () -> ((), Just (const vs))
,onRefresh = \r () v -> ((),(\(vt, _) -> (vt, r)) <$> v,Nothing)
} (attributes @>> editor) @ (\(_,(_,sel)) -> fromView container sel)
} (attributes @>> editor) @ (\(_,sel) -> fromView container sel)
editSharedSelectionWithShared :: ![SelectOption c a] (sds1 () c w) (Shared sds2 [Int]) -> Task [a] | iTask c & iTask a & TC w & RWShared sds1 & RWShared sds2
editSharedSelectionWithShared options sharedContainer sharedSel
......@@ -182,7 +182,7 @@ editSharedSelectionWithShared` attributes (SelectUsing toView fromView editor) s
{onInit = \(rc, rs) -> ((), Update (toView rc,rs))
,onEdit = \(_, vs) () -> ((), Just (const vs))
,onRefresh = \(rc, rs) _ _ -> ((), Just (toView rc, rs), Nothing)
} (attributes @>> editor) @ (\(_,(_,sel)) -> sel))
} (attributes @>> editor) @ snd)
-&&- watch sharedContainer //TEMPORARY: Don't use an extra task here
) @ (\(sel,container) -> fromView container sel)
) <<@ ApplyLayout unwrapUI
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment