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

IO/FFI Standard #336

Merged
merged 5 commits into from
May 23, 2024
Merged

IO/FFI Standard #336

merged 5 commits into from
May 23, 2024

Commits on May 22, 2024

  1. WIP

    VictorTaelin committed May 22, 2024
    Configuration menu
    Copy the full SHA
    ad8ddb7 View commit details
    Browse the repository at this point in the history
  2. IO/FFI Standard

    IO works by a simple a monadic FFI interface:
    
    type IO:
      Done { magic, expr }
      Call { magic, func, argm, cont }
    
    It provides a minimal mechanism to call an external function ('func')
    with a given Port argument ('argm') and a Port->Port continuation
    ('cont'). The function is just a name, which links to a native function
    with type:
    
    Port (*func)(Net*, Book*, Port);
    
    This is called from inside `do_run_io`, which is now called on main,
    instead of `normalize`. The 'magic' field is a constant, which we use to
    tell whether a given program is meant to do IO, without needing external
    flags or pragmas. If the normal form of the program is an ADT with the
    magic word, we treat it is an IO. Otherwise, we just normalize it.
    
    void do_run_io(Net* net, Book* book, Port port) {
      // IO loop
      while (TRUE) {
        // Normalizes the net
        normalize(net, book);
    
        // Reads the λ-Encoded Ctr
        Ctr ctr = read_ctr(net, book, peek(net, port));
    
        // Checks if IO Magic Number is a CON
        ...
    
        // Dispatches to the foreign function
        switch (ctr.tag) {
          case IO_CALL: ... call ...
          case IO_DONE: ... stop ...
        }
      }
    }
    
    Right now, we provide some builtin IOs, but this is meant to be
    extensible with user-defined fns in a future extension.
    
    This hasn't been implemented in CUDA yet.
    
    SDL (and graphics) is still disabled.
    VictorTaelin committed May 22, 2024
    Configuration menu
    Copy the full SHA
    4e0bc57 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6af6480 View commit details
    Browse the repository at this point in the history

Commits on May 23, 2024

  1. update snapshot

    VictorTaelin committed May 23, 2024
    Configuration menu
    Copy the full SHA
    833cac3 View commit details
    Browse the repository at this point in the history
  2. make examples smaller

    VictorTaelin committed May 23, 2024
    Configuration menu
    Copy the full SHA
    91bf1f4 View commit details
    Browse the repository at this point in the history