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

Make external-types.md compile with gleam 0.3 #263

Merged
merged 1 commit into from
Jul 16, 2023

Conversation

chiroptical
Copy link
Contributor

I looked at the order of push and noticed it was wrong. Then, I wanted to play with the example and it didn't compile. This should compile and work now. Unsure if any other changes need to be made.

chiroptical@Barrys-MacBook-Air ~/p/g/test (main)> cat src/test.gleam
import gleam/io

pub type Queue(a)

@external(erlang, "queue", "new")
pub fn new() -> Queue(a)

@external(erlang, "queue", "len")
pub fn length(queue: Queue(a)) -> Int

@external(erlang, "queue", "in")
pub fn push(elem: a, queue: Queue(a)) -> Queue(a)


pub fn main() {
  let queue = new()
  io.debug(length(queue))
  let new_queue = push(0, queue)
  io.debug(length(new_queue))
}
chiroptical@Barrys-MacBook-Air ~/p/g/test (main)> gleam --version
gleam 0.30.0
chiroptical@Barrys-MacBook-Air ~/p/g/test (main)> gleam run
  Compiling gleam_stdlib
  Compiling gleeunit
  Compiling test
   Compiled in 0.01s
    Running test.main
0
1

@@ -155,14 +155,14 @@ <h1 id="external-type"><a class="header" href="#external-type">External type</a>
<code>queue</code> module to work with the new <code>Queue</code> type.</p>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ran make with mdbook, but my guess is that the version I got is different and made a lot of other changes.

I only accepted the obvious changes.

@external(erlang, "queue" "in")
pub fn push(Queue(a), a) -> Queue(a)
@external(erlang, "queue", "in")
pub fn push(new: a, queue: Queue(a)) -> Queue(a)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to change the name new here.

@chiroptical
Copy link
Contributor Author

Closes #256 (I think)

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

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

Amazing, thank you!

@lpil lpil merged commit 0cbf9b4 into gleam-lang:main Jul 16, 2023
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.

2 participants