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 BUILTINS.MD #492

Merged
merged 30 commits into from
May 27, 2024
Merged

Add BUILTINS.MD #492

merged 30 commits into from
May 27, 2024

Conversation

Sipher
Copy link
Member

@Sipher Sipher commented May 24, 2024

Added the file BUILTINS.MD as a TODO. The plan is to start working on it or have at least some clarity before doing the book (some sort of WIP / POC)

removed the .com on the readme.md

@Sipher Sipher requested a review from developedby May 24, 2024 16:58
@Sipher Sipher self-assigned this May 24, 2024
@Sipher Sipher added the documentation Improvements or additions to documentation label May 24, 2024
@Sipher Sipher added the enhancement New feature or request label May 24, 2024
@Sipher Sipher linked an issue May 24, 2024 that may be closed by this pull request
@kings177
Copy link
Member

kings177 commented May 24, 2024

This should be Squashed.

BUILTINS.md Outdated
Comment on lines 107 to 119
STRING_NIL_TAG = 0
STRING_CONS_TAG = 1
```

```bend
IO_DONE_TAG = 0
IO_PUT_TEXT_TAG = 1
IO_GET_TEXT_TAG = 2
IO_WRITE_FILE_TAG = 3
IO_READ_FILE_TAG = 4
IO_GET_TIME_TAG = 5
IO_SLEEP_TAG = 6
IO_DRAW_IMAGE_TAG = 7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section about tags is outdated and should be removed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

BUILTINS.md Outdated
## Types

### String
```bend
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although we want to have bend to indicate that this is a bend program, github doesn't yet support it for syntax highlighting. I've been using either python or rust depending on what looks better on each specific example

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed some ot pythjon and some to rust, and it looks great indeed


- **Nil**: Represents an empty string.
- **Cons head ~tail**: Represents a string with a `head` character and a `tail` string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention that we have syntax for these types, maybe explain it here or maybe point to the syntax reference.

BUILTINS.md Outdated
Comment on lines 124 to 132
data IO
= (Done term)
| (PutText text cont)
| (GetText cont)
| (WriteFile file data cont)
| (ReadFile file cont)
| (GetTime cont)
| (Sleep time cont)
| (DrawImage tree cont)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type definition is outdated

Copy link
Member Author

@Sipher Sipher May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it there a place where I can find a more up to date version?

BUILTINS.md Outdated
```

### print
Prints text to the console.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Prints text to the console.
Prints text to the console (to stdout).

BUILTINS.md Outdated
```

### IO/bind
Chains IO operations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we need to explain how the bind syntax works

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it there a section or place where I can find a clear explanation on this? The last missing piece

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@developedby developedby May 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inside a do Type block, you can do a monadic call with <- or ask (depending on the syntax).

Each <- is converted into a call to the bind function Type/bind(asked, λvar: next)

For example:

do MyType:
  x <- Foo
  y = Bar
  z <- Baz
  return Something(x, y, z)

becomes

(MyType/bind Foo λx let y = Bar; (MyType/Bind Baz λz (Something x y z))

@developedby developedby added this pull request to the merge queue May 27, 2024
Merged via the queue into HigherOrderCO:main with commit 0433311 May 27, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add documentation on builtin types and functions
3 participants