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 84
    • Issues 84
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 10
    • Merge Requests 10
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • clean-and-itasks
  • iTasks-SDK
  • Issues
  • #370

Closed
Open
Opened Feb 17, 2020 by Camil Staps@cstaps🚀Owner0 of 1 task completed0/1 task

Return arbitrary value from upd

@baslijns and I were discussing the case where you want to do an upd and return the old value of the share. For example, you have some [a] of which you want to retrieve all values and set the value to []. It is my understanding that with a get followed by a set you might lose data and due to the type of upd (which always returns the new value) you cannot get the old value.

Assuming the current library indeed does not provide an easy way to do this, we would propose to change the type of upd from

upd :: !(r -> w) !(sds () r w) -> Task w | TC r & TC w & RWShared sds

to

upd :: !(r -> (a, Maybe w)) !(sds () r w) -> Task a | TC r & TC w & RWShared sds

where the share is only written when a Just is returned.

The old upd f can be expressed as upd (\old -> let new = f old in (new, Just new)), and get can be expressed as upd (flip tuple Nothing).

This has two advantages:

  1. You can return any a (e.g. the original value in the example above);
  2. upd can choose depending on the current value whether a new value should be written.

Problem: naming. Assuming that we want this function, do we want to change the current upd (our preference) or introduce a new name (and which)? upd is used 143 times in iTasks (examples included) and 7 times in VIIA.

cc @mlubbers @smichels @rinus

Cases where the new upd should be used:

  • https://gitlab.science.ru.nl/clean-and-itasks/iTasks-SDK/blob/1fb9f920b2e1b32a0fb52bb95b43893416ca5d8c/Libraries/iTasks/Internal/TaskEval.icl#L98
Edited Feb 25, 2020 by Camil Staps
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: clean-and-itasks/iTasks-SDK#370