Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Task as a built-in module/type #6836

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

smores56
Copy link
Sponsor Collaborator

@smores56 smores56 commented Jun 25, 2024

This change moves the Task opaque IO type from platform-specific implementations to the standard library of Roc. This PR is ready for review, barring final testing by building a pre-release of basic-cli using the twin basic-cli PR. The high level changes are:

  • Copied the Task module from the basic-cli platform to crates/compiler/builtins/roc/Task.roc
  • Consolidated Task and Effect into just the Task opaque type with definition Task ok err := {} -> Result ok err, which is the old type for Effect a : {} -> a that Task ok err : Effect (Result ok err) wrapped
  • Removed the Effect generation code, as everything should use Task directly
    • This includes the generates Effect with [after, map, ...] clause of the hosted module header, which is a breaking change
    • FFI definitions on the host side need to return RocResults now, and FFI type declarations on the Roc side need to always have Task return types
    • Removed generation of the Effect.after, Effect.map, etc. functions as they were needed to glue Effect to Task, but are no longer needed now that those types have been combined
  • Renamed hosted modules that contain FFI Roc declarations from Effect.roc to PlatformTask.roc to distinguish their behavior from the old approach and to give a name more descriptive of the new behavior
  • Updated almost of the testing, but until basic-cli works, that is on hold

@lukewilliamboswell
Copy link
Collaborator

It looks like there is a genuine issue with the False interpreter.

(nix:nix-shell-env) 192-168-1-103:false-interpreter luke$ roc build False.roc
🔨 Rebuilding platform...
0 errors and 0 warnings found in 940 ms
 while successfully building:

    False
(nix:nix-shell-env) 192-168-1-103:false-interpreter luke$ ./False examples/sqrt.false
Ran into problem:
examples/sqrt.false

@ageron
Copy link
Contributor

ageron commented Jul 29, 2024

Task.sequence runs tasks in reverse order, please see roc-lang/basic-cli#235

@Anton-4
Copy link
Collaborator

Anton-4 commented Jul 29, 2024

TODO: rename Task.seq to Task.sequence. This was a recent change.

@Anton-4
Copy link
Collaborator

Anton-4 commented Jul 29, 2024

TODO from Richard:

I suspect this will be a lot faster by doing appends while building it up and then doing one reverse at the end

@smores56 smores56 marked this pull request as ready for review July 31, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants