Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
I
iTasks-SDK
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 74
    • Issues 74
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 6
    • Merge Requests 6
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • clean-and-itasks
  • iTasks-SDK
  • Issues
  • #258

Closed
Open
Opened Oct 18, 2018 by Steffen Michels@smichelsMaintainer

Parametic Editors

I propose to introduce an additional type parameter for editors.

Currently, the type of editors is Editor a. The type indicates the value an editor works on. Such value is given if the editor is created in update/view, but not in enter mode. Furthermore, an editor can either be in an empty/invalid state without producing a value or in a valid state producing a value.

I propose to extend the type to Editor p a. The editor always gets additional parameter information of type p, so also in enter mode. The second type parameter is the value the editors works on, basically the same way as it does currently.

I'll give two example to demonstrate thy this is necessary:

We can't really type an editor for choosing a single value with the current type. With a single value we have to use the type Editor ([a], Int). The problem is that in enter mode there is no value, so we can't provide the list of options as input. As a workaround we have to use a type such as Editor ([a], Maybe Int). Then we can use combinators to map enter mode to updating (choices, Nothing), this is more or less how it works now. This is of course not very neat, as the editor will always have a value then, also in case nothing is chosen.

As second example consider something as the input field of google. You can type in things, but there is also a list of suggestions. This will never work reliably with a type Editor ([String], String). At the moment you want to update the suggestions, you have no choice but to also set the value, the user is typing in, i.e. (suggestions, curValue). The curValue on the server may however be outdated and all characters the user typed in since the last edit event was processed will be removed.

Of course, this will make the editor combinators and usage more complicated, but I think we can restrict the complexity for cases the parameter is not required. I haven't though this out, but I think it should be possible to do something like this:

:: ParamEditor p a = ...
:: Editor a :== ParamEditor () a

Then the type of the current combinators and options doesn't have to be changed. For instance, we can add a new constructor to UpdateOption and leave the others as they are:

:: UpdateOption a b
	= E.v: UpdateAs (a -> v) (a -> v -> b) & iTask v
	| E.v: UpdateUsing (a -> v) (a -> v -> b) (Editor v) & iTask v
	| E.v: UpdateSharedAs (a -> v) (a -> v -> b) (v -> v -> v) & iTask v
        | E.p v: UpdateUsingParamEditor (a -> (p, v)) (a -> v -> b) (ParamEditor p v) & iTask v
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: clean-and-itasks/iTasks-SDK#258