Commit 131c56ee authored by Camil Staps's avatar Camil Staps 🚀

Documentation & code style for !325

parent 28023ea7
Pipeline #29916 passed with stage
in 4 minutes and 39 seconds
......@@ -67,19 +67,17 @@ accWorldOSError :: !(*World -> (MaybeOSError a, *World)) -> Task a |
:: OSException = OSException !OSError
instance toString OSException
/**
* Core interaction task. All other interaction tasks are derived from this one.
* There are two almost identical versions:
* The `interactRW` version can update the given sds.
* The `interactR` version only reads, which means it can also be used for sds's that are not writable.
*/
:: InteractionHandlers l r w v =
{ onInit :: !(r -> (l, EditMode v))
, onEdit :: !(v l -> (l, Maybe (r -> w)))
, onRefresh :: !(r l (Maybe v) -> (l, Maybe v, Maybe (r -> w)))
{ onInit :: !(r -> (l, EditMode v))
, onEdit :: !(v l -> (l, Maybe (r -> w)))
, onRefresh :: !(r l (Maybe v) -> (l, Maybe v, Maybe (r -> w)))
}
//Version which can write shared data
/**
* 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
//Version which does not write shared data
//* 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
......@@ -151,13 +151,13 @@ evalInteract l v mst mode sds handlers editor writefun ResetEvent evalOpts=:{tas
, iworld)
evalInteract l v mst mode sds handlers editor writefun event=:(RefreshEvent taskIds _) evalOpts=:{taskId,lastEval} iworld
| 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))
(\r event evalOpts iworld
# (l, mbV, mbf) = handlers.InteractionHandlers.onRefresh r l v
# st = fromJust mst
# mbChange = case mbV of
Just v = withVSt taskId (editor.Editor.onRefresh [] v (fromJust mst)) iworld
Just v = withVSt taskId (editor.Editor.onRefresh [] v st) iworld
Nothing = (Ok (NoChange, st), iworld)
= case mbChange of
(Error e, iworld) = (ExceptionResult (exception e), iworld)
......
......@@ -20,13 +20,16 @@ from Data.Functor import class Functor
= E.v: UpdateAs (a -> v) (a v -> a) & iTask v
| E.v: UpdateUsing (a -> v) (a v -> a) (Editor v) & iTask v
//When using an shared data you have to supply an additional
//conflict resolution function (v v -> v)
//When both the view has been edited, and the sds has changed, this
//function determines what the new view should be.
//The first argument is the new view as computed from the changed sds,
//and the second argument is the edited view by the user, if the current view represents a valid value.
//If the result is `Nothing` the view is not updated.
/**
* When using an shared data you have to supply an additional conflict
* resolution function `(v (Maybe v) -> Maybe v)`. When both the view has been
* edited, and the sds has changed, this function determines what the new view
* should be.
* The first argument is the new view as computed from the changed sds, and the
* second argument is the edited view by the user, if the current view
* represents a valid value.
* If the result is `Nothing` the view is not updated.
*/
:: UpdateSharedOption a b
= E.v: UpdateSharedAs (a -> v) (a v -> b) (v (Maybe v) -> Maybe v) & iTask v
| E.v: UpdateSharedUsing (a -> v) (a v -> b) (v (Maybe v) -> Maybe v) (Editor v) & iTask v
......
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