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

Create spec #309

Open
pbiggar opened this issue Oct 19, 2022 · 0 comments
Open

Create spec #309

pbiggar opened this issue Oct 19, 2022 · 0 comments

Comments

@pbiggar
Copy link
Member

pbiggar commented Oct 19, 2022

I've been thinking through multiple iterations of how we'd spec functions, including #307, #288 and #299. This idea maybe solves all three.

We should have a set of yaml files, one for each function. These files would specify the function name, the module, test cases, examples, docstrings, parameter types and names. Basically, anything which is useful for automatically generating tests, docs, templates, etc.

For example, we could have Int.add.yaml, with the following contents:

module: Int
name: add
docstring: Add <param a> to <param b>, returning their sum
parameters:
  - name: a
    type: int
  - name: b
    type: int
returnType: int
# For compatibility
constraints:
  - no-ocaml
  - no-rescript
tests:
  - inputs: [1,2]
    output: 3
  - inputs: [1,1]
    output: 2
examples:
  - inputs: [1,2]
    output: 3
  - inputs: [1,1]
    output: 2
added: 0.1.0 # We can use 0.1.0 for all of these for now

Given this, we can add some scripts in rescript that reads these and generates:

  • test files for each language
  • a markdown page with tests, docstrings and compatibility
  • interface files for each language

Possibly there would be one script that accepts format strings so we could reuse it to do all this, but that's just an idea.

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

No branches or pull requests

1 participant