Commit df8b04d8 authored by Bas Lijnse's avatar Bas Lijnse

Merge branch...

Merge branch '222-graph_to_sapl_string-seems-to-get-stuck-1024m-heap-and-128m-stack-are-not-enough' into 'master'

Resolve "graph_to_sapl_string seems to get stuck (1024M Heap and 128M Stack are not enough)"

See merge request !157
parents 1603eed2 ac600c15
......@@ -63,10 +63,10 @@ withClientSideInit ::
withClientSideInit initUI genUI dp val vst=:{VSt|taskId} = case genUI dp val vst of
(Ok (UI type attr items,mask),vst=:{VSt|iworld}) = case editorLinker initUI iworld of
(Ok (saplDeps, saplInit),iworld)
# extraAttr = 'DM'.fromList [("taskId",JSONString taskId)
,("editorId",JSONString (editorId dp))
,("saplDeps",JSONString saplDeps)
,("saplInit",JSONString saplInit)
# extraAttr = 'DM'.fromList [("taskId", JSONString taskId)
,("editorId",JSONString (editorId dp))
,("saplDeps",JSONString saplDeps)
,("saplInit",JSONString saplInit)
]
= (Ok (UI type ('DM'.union extraAttr attr) items,mask), {VSt|vst & iworld = iworld})
(Error e,iworld)
......
......@@ -12,111 +12,111 @@ from Text.GenJSON import :: JSONNode
//# UIContainer
container :: Editor ()
containerl :: (Editor a) -> Editor [a]
containerL :: [Editor a] -> Editor [a]
container1 :: (Editor a) -> Editor a
container2 :: (Editor a) (Editor b) -> Editor (a,b)
container3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
container4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
container5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
containerc :: (Editor Int) [(a -> a, Editor a)] -> Editor (Int, a)
containerl :: !(Editor a) -> Editor [a]
containerL :: ![Editor a] -> Editor [a]
container1 :: !(Editor a) -> Editor a
container2 :: !(Editor a) !(Editor b) -> Editor (a,b)
container3 :: !(Editor a) !(Editor b) !(Editor c) -> Editor (a,b,c)
container4 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) -> Editor (a,b,c,d)
container5 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) !(Editor e) -> Editor (a,b,c,d,e)
containerc :: !(Editor Int) ![(a -> a, Editor a)] -> Editor (Int, a)
//# UIPanel
panel :: Editor ()
panell :: (Editor a) -> Editor [a]
panelL :: [Editor a] -> Editor [a]
panel1 :: (Editor a) -> Editor a
panel2 :: (Editor a) (Editor b) -> Editor (a,b)
panel3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
panel4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
panel5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
panelc :: (Editor Int) [(a -> a, Editor a)] -> Editor (Int, a)
panell :: !(Editor a) -> Editor [a]
panelL :: ![Editor a] -> Editor [a]
panel1 :: !(Editor a) -> Editor a
panel2 :: !(Editor a) !(Editor b) -> Editor (a,b)
panel3 :: !(Editor a) !(Editor b) !(Editor c) -> Editor (a,b,c)
panel4 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) -> Editor (a,b,c,d)
panel5 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) !(Editor e) -> Editor (a,b,c,d,e)
panelc :: !(Editor Int) ![(a -> a, Editor a)] -> Editor (Int, a)
//# UITabSet
tabset :: Editor ()
tabsetl :: (Editor a) -> Editor [a]
tabsetL :: [Editor a] -> Editor [a]
tabset1 :: (Editor a) -> Editor a
tabset2 :: (Editor a) (Editor b) -> Editor (a,b)
tabset3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
tabset4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
tabset5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
tabsetc :: (Editor Int) [(a -> a, Editor a)] -> Editor (Int, a)
tabsetl :: !(Editor a) -> Editor [a]
tabsetL :: ![Editor a] -> Editor [a]
tabset1 :: !(Editor a) -> Editor a
tabset2 :: !(Editor a) !(Editor b) -> Editor (a,b)
tabset3 :: !(Editor a) !(Editor b) !(Editor c) -> Editor (a,b,c)
tabset4 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) -> Editor (a,b,c,d)
tabset5 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) !(Editor e) -> Editor (a,b,c,d,e)
tabsetc :: !(Editor Int) ![(a -> a, Editor a)] -> Editor (Int, a)
//# UIWindow
window :: Editor ()
windowl :: (Editor a) -> Editor [a]
windowL :: [Editor a] -> Editor [a]
window1 :: (Editor a) -> Editor a
window2 :: (Editor a) (Editor b) -> Editor (a,b)
window3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
window4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
window5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
windowc :: (Editor Int) [(a -> a, Editor a)] -> Editor (Int, a)
windowl :: !(Editor a) -> Editor [a]
windowL :: ![Editor a] -> Editor [a]
window1 :: !(Editor a) -> Editor a
window2 :: !(Editor a) !(Editor b) -> Editor (a,b)
window3 :: !(Editor a) !(Editor b) !(Editor c) -> Editor (a,b,c)
window4 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) -> Editor (a,b,c,d)
window5 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) !(Editor e) -> Editor (a,b,c,d,e)
windowc :: !(Editor Int) ![(a -> a, Editor a)] -> Editor (Int, a)
//# UIMenu
menu :: Editor ()
menul :: (Editor a) -> Editor [a]
menuL :: [Editor a] -> Editor [a]
menu1 :: (Editor a) -> Editor a
menu2 :: (Editor a) (Editor b) -> Editor (a,b)
menu3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
menu4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
menu5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
menuc :: (Editor Int) [(a -> a, Editor a)] -> Editor (Int, a)
menul :: !(Editor a) -> Editor [a]
menuL :: ![Editor a] -> Editor [a]
menu1 :: !(Editor a) -> Editor a
menu2 :: !(Editor a) !(Editor b) -> Editor (a,b)
menu3 :: !(Editor a) !(Editor b) !(Editor c) -> Editor (a,b,c)
menu4 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) -> Editor (a,b,c,d)
menu5 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) !(Editor e) -> Editor (a,b,c,d,e)
menuc :: !(Editor Int) ![(a -> a, Editor a)] -> Editor (Int, a)
//# UIToolBar
toolbar :: Editor ()
toolbarl :: (Editor a) -> Editor [a]
toolbarL :: [Editor a] -> Editor [a]
toolbar1 :: (Editor a) -> Editor a
toolbar2 :: (Editor a) (Editor b) -> Editor (a,b)
toolbar3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
toolbar4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
toolbar5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
toolbarc :: (Editor Int) [(a -> a, Editor a)] -> Editor (Int, a)
toolbarl :: !(Editor a) -> Editor [a]
toolbarL :: ![Editor a] -> Editor [a]
toolbar1 :: !(Editor a) -> Editor a
toolbar2 :: !(Editor a) !(Editor b) -> Editor (a,b)
toolbar3 :: !(Editor a) !(Editor b) !(Editor c) -> Editor (a,b,c)
toolbar4 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) -> Editor (a,b,c,d)
toolbar5 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) !(Editor e) -> Editor (a,b,c,d,e)
toolbarc :: !(Editor Int) ![(a -> a, Editor a)] -> Editor (Int, a)
//# UIButtonBar
buttonbar :: Editor ()
buttonbarl :: (Editor a) -> Editor [a]
buttonbarL :: [Editor a] -> Editor [a]
buttonbar1 :: (Editor a) -> Editor a
buttonbar2 :: (Editor a) (Editor b) -> Editor (a,b)
buttonbar3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
buttonbar4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
buttonbar5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
buttonbarc :: (Editor Int) [(a -> a, Editor a)] -> Editor (Int, a)
buttonbarl :: !(Editor a) -> Editor [a]
buttonbarL :: ![Editor a] -> Editor [a]
buttonbar1 :: !(Editor a) -> Editor a
buttonbar2 :: !(Editor a) !(Editor b) -> Editor (a,b)
buttonbar3 :: !(Editor a) !(Editor b) !(Editor c) -> Editor (a,b,c)
buttonbar4 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) -> Editor (a,b,c,d)
buttonbar5 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) !(Editor e) -> Editor (a,b,c,d,e)
buttonbarc :: !(Editor Int) ![(a -> a, Editor a)] -> Editor (Int, a)
//# UIList
list :: Editor ()
listl :: (Editor a) -> Editor [a]
listL :: [Editor a] -> Editor [a]
list1 :: (Editor a) -> Editor a
list2 :: (Editor a) (Editor b) -> Editor (a,b)
list3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
list4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
list5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
listc :: (Editor Int) [(a -> a, Editor a)] -> Editor (Int, a)
listl :: !(Editor a) -> Editor [a]
listL :: ![Editor a] -> Editor [a]
list1 :: !(Editor a) -> Editor a
list2 :: !(Editor a) !(Editor b) -> Editor (a,b)
list3 :: !(Editor a) !(Editor b) !(Editor c) -> Editor (a,b,c)
list4 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) -> Editor (a,b,c,d)
list5 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) !(Editor e) -> Editor (a,b,c,d,e)
listc :: !(Editor Int) ![(a -> a, Editor a)] -> Editor (Int, a)
//# UIListItem
listitem :: Editor ()
listiteml :: (Editor a) -> Editor [a]
listitemL :: [Editor a] -> Editor [a]
listitem1 :: (Editor a) -> Editor a
listitem2 :: (Editor a) (Editor b) -> Editor (a,b)
listitem3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
listitem4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
listitem5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
listitemc :: (Editor Int) [(a -> a, Editor a)] -> Editor (Int, a)
listiteml :: !(Editor a) -> Editor [a]
listitemL :: ![Editor a] -> Editor [a]
listitem1 :: !(Editor a) -> Editor a
listitem2 :: !(Editor a) !(Editor b) -> Editor (a,b)
listitem3 :: !(Editor a) !(Editor b) !(Editor c) -> Editor (a,b,c)
listitem4 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) -> Editor (a,b,c,d)
listitem5 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) !(Editor e) -> Editor (a,b,c,d,e)
listitemc :: !(Editor Int) ![(a -> a, Editor a)] -> Editor (Int, a)
//# UIDebug
debug :: Editor ()
debugl :: (Editor a) -> Editor [a]
debugL :: [Editor a] -> Editor [a]
debug1 :: (Editor a) -> Editor a
debug2 :: (Editor a) (Editor b) -> Editor (a,b)
debug3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
debug4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
debug5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
debugc :: (Editor Int) [(a -> a, Editor a)] -> Editor (Int, a)
debugl :: !(Editor a) -> Editor [a]
debugL :: ![Editor a] -> Editor [a]
debug1 :: !(Editor a) -> Editor a
debug2 :: !(Editor a) !(Editor b) -> Editor (a,b)
debug3 :: !(Editor a) !(Editor b) !(Editor c) -> Editor (a,b,c)
debug4 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) -> Editor (a,b,c,d)
debug5 :: !(Editor a) !(Editor b) !(Editor c) !(Editor d) !(Editor e) -> Editor (a,b,c,d,e)
debugc :: !(Editor Int) ![(a -> a, Editor a)] -> Editor (Int, a)
This diff is collapsed.
......@@ -10,7 +10,7 @@ from System.Time import :: Timestamp
from iTasks.Internal.Generic.Visualization import generic gText, :: TextFormat
/**
* Main eneric editor function
* Main generic editor function
*/
generic gEditor a | gText a, gDefault a, JSONEncode a, JSONDecode a :: Editor a
......
This diff is collapsed.
......@@ -6,41 +6,42 @@ import iTasks.UI.Editor, iTasks.UI.Definition, iTasks.UI.Tune
import Data.Error
//### Modifying atributes of editors ###
/*
* Preseeds the value when an EnterInformation is given
*/
withPreseededValue :: a !(Editor a) -> Editor a
/**
* Adds UI attributes to an editor
*/
withAttributes :: UIAttributes (Editor a) -> Editor a
withAttributes :: !UIAttributes !(Editor a) -> Editor a
instance tune UIAttributes Editor
/*
* Preseeds the value when an EnterInformation is given
*/
withPreseededValue :: a (Editor a) -> Editor a
/**
* Adds a label attribute
* This does not create the actual label ui component, that is normally done by a layout
*/
withLabelAttr :: String (Editor a) -> Editor a
withLabelAttr :: !String !(Editor a) -> Editor a
/**
* Adds an attribute that tags the UI with the edit mode of the editor: view, enter, update
* This does not change the mode of the editor
*/
withEditModeAttr :: (Editor a) -> Editor a
withEditModeAttr :: !(Editor a) -> Editor a
/**
* Adds a hint and hint-type attribute based on the editor's state.
* Layouts (such as the automatic default layout) can use these attributes to create hint icons and tooltips
*/
withDynamicHintAttributes :: String (Editor a) -> Editor a
withDynamicHintAttributes :: !String !(Editor a) -> Editor a
//### Changing the edit mode ###
/*
* Override the edit mode (view/enter/update)
*/
withEditMode :: EditMode (Editor a) -> Editor a
withEditMode :: !EditMode !(Editor a) -> Editor a
/**
* Selecting between editors based on the edit mode of the interaction (view/enter/update)
......@@ -49,7 +50,7 @@ withEditMode :: EditMode (Editor a) -> Editor a
* @param Editor for entering a value
* @param Editor for updating a value
*/
selectByMode :: (Editor a) (Editor a) (Editor a) -> Editor a
selectByMode :: !(Editor a) !(Editor a) !(Editor a) -> Editor a
// ### Changing the model value of the editor ###
......@@ -57,21 +58,21 @@ selectByMode :: (Editor a) (Editor a) (Editor a) -> Editor a
/**
* Map the value of an editor to another (isomorphic) domain
*/
bijectEditorValue :: (a -> b) (b -> a) (Editor b) -> Editor a
bijectEditorValue :: !(a -> b) !(b -> a) !(Editor b) -> Editor a
/**
* Map the value of an editor to another domain which is 'bigger' than the original domain
* so conversion back to the original is not always possible
*/
injectEditorValue :: (a -> b) (b -> MaybeErrorString a) (Editor b) -> Editor a | JSONEncode{|*|} b & JSONDecode{|*|} b
injectEditorValue :: !(a -> b) !(b -> MaybeErrorString a) !(Editor b) -> Editor a | JSONEncode{|*|} b & JSONDecode{|*|} b
/**
* Map the value of an editor to another domain which is 'smaller' than the original domain
*/
surjectEditorValue :: (a -> b) (b a -> a) (Editor b) -> Editor a | JSONEncode{|*|} b & JSONDecode{|*|} b
surjectEditorValue :: !(a -> b) !(b a -> a) !(Editor b) -> Editor a | JSONEncode{|*|} b & JSONDecode{|*|} b
/**
* Map the value of an editor to another domain, without mapping changes in the editor back
*/
comapEditorValue :: (b -> a) (Editor a) -> Editor b
comapEditorValue :: !(b -> a) !(Editor a) -> Editor b
......@@ -7,15 +7,16 @@ import Data.Error, Text.GenJSON
import Data.GenEq
import qualified Data.Map as DM
withPreseededValue :: a (Editor a) -> Editor a
withPreseededValue def editor =
withEditMode Update {Editor|editor & genUI = const o flip editor.genUI def}
withPreseededValue :: a !(Editor a) -> Editor a
withPreseededValue def editor=:{Editor | genUI=genUI}
= withEditMode Update {Editor|editor & genUI = const o flip genUI def}
withAttributes :: UIAttributes (Editor a) -> Editor a
withAttributes extra editor = {Editor|editor & genUI = genUI}
withAttributes :: !UIAttributes !(Editor a) -> Editor a
withAttributes extra editor=:{genUI=editorGenUI}
= {Editor|editor & genUI = genUI}
where
genUI dp val vst=:{VSt|taskId,optional}
= case editor.Editor.genUI dp val vst of
= case editorGenUI dp val vst of
(Ok (UI type attr items,mask),vst) = (Ok (UI type ('DM'.union attr extra) items,mask),vst)
(e,vst) = (e,vst)
......@@ -23,22 +24,24 @@ instance tune UIAttributes Editor
where
tune attr editor = withAttributes attr editor
withLabelAttr :: String (Editor a) -> Editor a
withLabelAttr :: !String !(Editor a) -> Editor a
withLabelAttr label editor = withAttributes (labelAttr label) editor
withEditModeAttr :: (Editor a) -> Editor a
withEditModeAttr editor = {Editor|editor & genUI = genUI}
withEditModeAttr :: !(Editor a) -> Editor a
withEditModeAttr editor=:{genUI=editorGenUI}
= {Editor|editor & genUI = genUI}
where
genUI dp val vst=:{VSt|taskId,mode}
= case editor.Editor.genUI dp val vst of
= case editorGenUI dp val vst of
(Ok (UI type attr items,mask),vst) = (Ok (UI type ('DM'.put "mode" (JSONString (toString mode)) attr) items, mask),vst)
(e,vst) = (e,vst)
withDynamicHintAttributes :: String (Editor a) -> Editor a
withDynamicHintAttributes typeDesc editor = {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
withDynamicHintAttributes :: !String !(Editor a) -> Editor a
withDynamicHintAttributes typeDesc {genUI=editorGenUI,onEdit=editorOnEdit,onRefresh=editorOnRefresh}
= {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
where
genUI dp val vst=:{VSt|taskId,optional}
= case editor.Editor.genUI dp val vst of
= case editorGenUI dp val vst of
(Ok (UI type attr items,mask),vst)
//Add hint attributes
# attr = 'DM'.union (stdAttributes typeDesc optional mask) attr
......@@ -46,9 +49,9 @@ where
(e,vst) = (e,vst)
onEdit dp e oval omask vst=:{VSt|optional}
= addHintAttrChanges omask (editor.Editor.onEdit dp e oval omask vst)
= addHintAttrChanges omask (editorOnEdit dp e oval omask vst)
onRefresh dp e oval omask vst=:{VSt|optional}
= addHintAttrChanges omask (editor.Editor.onRefresh dp e oval omask vst)
= addHintAttrChanges omask (editorOnRefresh dp e oval omask vst)
addHintAttrChanges omask (Ok (change,nmask),nval,vst=:{VSt|optional})
# attrChange = case stdAttributeChanges typeDesc optional omask nmask of
......@@ -57,10 +60,11 @@ where
# change = mergeUIChanges change attrChange
= (Ok (change,nmask),nval,vst)
addHintAttrChanges omask (e,val,vst) = (e,val,vst)
/**
* Set basic hint and error information based on the verification
*/
stdAttributes :: String Bool EditMask -> UIAttributes
stdAttributes :: !String !Bool !EditMask -> UIAttributes
stdAttributes typename optional (CompoundMask _) = 'DM'.newMap
stdAttributes typename optional mask
# (touched,valid,state) = case mask of
......@@ -79,65 +83,73 @@ stdAttributes typename optional mask
= 'DM'.fromList [(HINT_TYPE_ATTRIBUTE,JSONString HINT_TYPE_INVALID)
,(HINT_ATTRIBUTE,JSONString ("This value not in the required format of a " +++ typename))]
stdAttributeChanges :: String Bool EditMask EditMask -> [UIAttributeChange]
stdAttributeChanges :: !String !Bool !EditMask !EditMask -> [UIAttributeChange]
stdAttributeChanges typename optional om nm
| om === nm = [] //Nothing to change
| otherwise = [SetAttribute k v \\ (k,v) <- 'DM'.toList (stdAttributes typename optional nm)]
selectByMode :: (Editor a) (Editor a) (Editor a) -> Editor a
selectByMode viewEditor enterEditor updateEditor= {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
selectByMode :: !(Editor a) !(Editor a) !(Editor a) -> Editor a
selectByMode
viewEditor =:{genUI=viewGenUI, onEdit=viewOnEdit, onRefresh=viewOnRefresh}
enterEditor =:{genUI=enterGenUI, onEdit=enterOnEdit, onRefresh=enterOnRefresh}
updateEditor=:{genUI=updateGenUI,onEdit=updateOnEdit,onRefresh=updateOnRefresh}
= {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
where
genUI dp val vst=:{VSt|mode} = case mode of
View = viewEditor.Editor.genUI dp val vst
Enter = enterEditor.Editor.genUI dp val vst
Update = updateEditor.Editor.genUI dp val vst
View = viewGenUI dp val vst
Enter = enterGenUI dp val vst
Update = updateGenUI dp val vst
onEdit dp e val mask vst=:{VSt|mode} = case mode of
View = viewEditor.Editor.onEdit dp e val mask vst
Enter = enterEditor.Editor.onEdit dp e val mask vst
Update = updateEditor.Editor.onEdit dp e val mask vst
View = viewOnEdit dp e val mask vst
Enter = enterOnEdit dp e val mask vst
Update = updateOnEdit dp e val mask vst
onRefresh dp new old mask vst=:{VSt|mode} = case mode of
View = viewEditor.Editor.onRefresh dp new old mask vst
Enter = enterEditor.Editor.onRefresh dp new old mask vst
Update = updateEditor.Editor.onRefresh dp new old mask vst
View = viewOnRefresh dp new old mask vst
Enter = enterOnRefresh dp new old mask vst
Update = updateOnRefresh dp new old mask vst
withEditMode :: EditMode (Editor a) -> Editor a
withEditMode newMode editor = {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
withEditMode :: !EditMode !(Editor a) -> Editor a
withEditMode newMode {genUI=editorGenUI,onEdit=editorOnEdit,onRefresh=editorOnRefresh}
= {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
where
genUI dp val vst=:{VSt|mode}
# (res,vst) = editor.Editor.genUI dp val {VSt|vst & mode = newMode}
# (res,vst) = editorGenUI dp val {VSt|vst & mode = newMode}
= (res,{VSt|vst & mode=mode})
onEdit dp e val mask vst=:{VSt|mode}
# (mask,val,vst) = editor.Editor.onEdit dp e val mask {VSt|vst & mode = newMode}
# (mask,val,vst) = editorOnEdit dp e val mask {VSt|vst & mode = newMode}
= (mask,val,{VSt|vst & mode=mode})
onRefresh dp new old mask vst=:{VSt|mode}
# (change,val,vst) = editor.Editor.onRefresh dp new old mask {VSt|vst & mode = newMode}
# (change,val,vst) = editorOnRefresh dp new old mask {VSt|vst & mode = newMode}
= (change,val,{VSt|vst & mode=mode})
bijectEditorValue :: (a -> b) (b -> a) (Editor b) -> Editor a
bijectEditorValue tof fromf editor = {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
bijectEditorValue :: !(a -> b) !(b -> a) !(Editor b) -> Editor a
bijectEditorValue tof fromf {genUI=editorGenUI,onEdit=editorOnEdit,onRefresh=editorOnRefresh}
= {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
where
genUI dp val vst = editor.Editor.genUI dp (tof val) vst
genUI dp val vst
= editorGenUI dp (tof val) vst
onEdit dp e val mask vst
# (mask,val,vst) = editor.Editor.onEdit dp e (tof val) mask vst
# (mask,val,vst) = editorOnEdit dp e (tof val) mask vst
= (mask,fromf val,vst)
onRefresh dp new old mask vst
# (change,val,vst) = editor.Editor.onRefresh dp (tof new) (tof old) mask vst
# (change,val,vst) = editorOnRefresh dp (tof new) (tof old) mask vst
= (change,fromf val,vst)
injectEditorValue :: (a -> b) (b -> MaybeErrorString a) (Editor b) -> Editor a | JSONEncode{|*|} b & JSONDecode{|*|} b
injectEditorValue tof fromf editor = {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
injectEditorValue :: !(a -> b) !(b -> MaybeErrorString a) !(Editor b) -> Editor a | JSONEncode{|*|} b & JSONDecode{|*|} b
injectEditorValue tof fromf {genUI=editorGenUI,onEdit=editorOnEdit,onRefresh=editorOnRefresh}
= {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
where
genUI dp val vst = case editor.Editor.genUI dp (tof val) vst of
genUI dp val vst = case editorGenUI dp (tof val) vst of
(Error e,vst) = (Error e,vst)
(Ok (ui,mask),vst) = (Ok (ui,StateMask mask (toJSON (tof val))), vst) //Track state of the 'inner' editor
onEdit dp e aval (StateMask mask encval) vst
# (Just bval) = fromJSON encval
= case editor.Editor.onEdit dp e bval mask vst of
= case editorOnEdit dp e bval mask vst of
(Error e, _, vst) = (Error e, aval, vst)
(Ok (change,mask), bval, vst) = case fromf bval of
(Ok aval) = (Ok (change,StateMask mask (toJSON bval)),aval,vst) //TODO: What about clearing the errors? track state...
......@@ -153,7 +165,7 @@ where
onRefresh dp newa olda (StateMask mask encval) vst
# (Just oldb) = fromJSON encval
= case editor.Editor.onRefresh dp (tof newa) oldb mask vst of
= case editorOnRefresh dp (tof newa) oldb mask vst of
(Error e, _, vst) = (Error e, olda, vst)
(Ok (change,mask), newb, vst) = case fromf newb of
(Ok newa) = (Ok (change,StateMask mask (toJSON newb)), newa, vst)
......@@ -167,32 +179,34 @@ where
= (change,mask)
= (Ok (change,StateMask mask (toJSON newb)), olda, vst)
surjectEditorValue :: (a -> b) (b a -> a) (Editor b) -> Editor a | JSONEncode{|*|} b & JSONDecode{|*|} b