roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
3.86k stars 284 forks source link

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

Open smores56 opened 1 week ago

smores56 commented 1 week ago

This is an in-progress PR that moves the Task opaque IO type from platform-specific implementations to the standard library of Roc. The main thrust of the implementation work is done, barring bug fixes and testing. The high level changes are:

I am running into an issue while testing this with a testing platform where Roc says the inferred types of our generated FFI function bodies don't match their type definitions for the Task return types:

── TYPE MISMATCH in examples/cli/false-interpreter/platform/PlatformTask.roc ───

Something is off with the body of the getLine definition:

This Task.Task opaque wrapping has the type:

    Task *

But the type annotation on getLine says it should be:

    Task Str

I did not make any real changes to how we generate the FFI calls, and we seem to define the return type based on the definition, but I'm sure I'm missing something. If anyone has any suggestions on how to debug or fix this issue, that would be appreciated.

I have created a twin PR for the basic-cli platform that can be useful for testing this change, as well as basing other platform updates on.

Since most of the cli_run tests depend on current basic-cli, expect the tests to fail on this PR for a bit.