Skip to content

GHC JS browser introduction blog post/tutorial #24

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

Merged
merged 28 commits into from
Jan 24, 2023

Conversation

JoshMeredith
Copy link
Contributor

No description provided.

Copy link
Contributor

@hsyl20 hsyl20 left a comment

Choose a reason for hiding this comment

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

It looks good, thanks Josh!

Copy link
Contributor

@doyougnu doyougnu left a comment

Choose a reason for hiding this comment

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

just a few minor things, no big restructuring! Good Job!

@hsyl20
Copy link
Contributor

hsyl20 commented Jan 10, 2023

As discussed in the GHC call, we should probably document clearly that the JS backend isn't feature complete yet to lower expectations (mentioning missing TH, etc.).

@JoshMeredith
Copy link
Contributor Author

As discussed in the GHC call, we should probably document clearly that the JS backend isn't feature complete yet to lower expectations (mentioning missing TH, etc.).

Is this appropriate for the conclusion section?

@hsyl20
Copy link
Contributor

hsyl20 commented Jan 10, 2023

As discussed in the GHC call, we should probably document clearly that the JS backend isn't feature complete yet to lower expectations (mentioning missing TH, etc.).

Is this appropriate for the conclusion section?

At the end of the introduction perhaps to be sure that most people read it?

@Swordlash
Copy link

Hey, is this possible to also add a small example of passing Haskell callback into foreign code? Something along the lines of

setOnBodyClick :: IO () -> IO ()
setOnBodyClick callback = ... some function calling document.body.onclick = (() => callback ())

(is it possible yet in the alpha?)

@hsyl20
Copy link
Contributor

hsyl20 commented Jan 16, 2023

Hey, is this possible to also add a small example of passing Haskell callback into foreign code? Something along the lines of

setOnBodyClick :: IO () -> IO ()
setOnBodyClick callback = ... some function calling document.body.onclick = (() => callback ())

(is it possible yet in the alpha?)

Hey, I was planning to answer your original comments about this (https://discourse.haskell.org/t/ghc-js-backend-calling-haskell-callback-in-a-foreign-function/5591) :)

I don't think this is supported yet. We've only ported basic foreign imports, not foreign exports nor magical foreign imports (wrapper, etc.).

@Swordlash
Copy link

Oh sorry, I thought you may have not seen it. Sorry then for polluting the PR.

@hsyl20
Copy link
Contributor

hsyl20 commented Jan 16, 2023

Oh sorry, I thought you may have not seen it. Sorry then for polluting the PR.

No problem! Thanks for trying the backend and for the nudge! :-) We'll try to prioritize foreign exports and to publish a blog post about them as soon as they are supported.

@JoshMeredith JoshMeredith changed the title WIP blog post & associated example code for GHC JS browser example GHC JS browser introduction blog post/tutorial Jan 18, 2023
Copy link
Contributor

@hsyl20 hsyl20 left a comment

Choose a reason for hiding this comment

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

I've left a few more comments.

Some of @doyougnu's comments don't appear anymore in the "changes" view afaict. For example I remember him asking for a screenshot of the result. That would be nice to have. I've re-added a comment about this.

Also the path of the md file isn't correct: it must be directly in the blog directly for it to be found by the blog engine (I think).

@doyougnu
Copy link
Contributor

doyougnu commented Jan 19, 2023

Also the path of the md file isn't correct: it must be directly in the blog directly for it to be found by the blog engine (I think).

I don't think we have a static asset folder defined in docusaurus.config.js, see the docs: https://docusaurus.io/docs/markdown-features/assets#static-assets

and I bet that's why docusaurus looks at blog, it must use the directory of the post as default or last-to-try

@JoshMeredith
Copy link
Contributor Author

Also the path of the md file isn't correct: it must be directly in the blog directly for it to be found by the blog engine (I think).

I don't think we have a static asset folder defined in docusaurus.config.js, see the docs: https://docusaurus.io/docs/markdown-features/assets#static-assets

and I bet that's why docusaurus looks at blog, it must use the directory of the post as default or last-to-try

Thanks for finding the setting! Hopefully it’s enough that I’ve added that now.

@doyougnu
Copy link
Contributor

just pushed a bunch of fixes. The conclusion needs to be fixed to not repeat (almost verbatim) the introduction. The conclusion should recite the entire post, but inside out (that is, started from the last thing in the post and work its way back to the introduction).

Other than that LGTM!

@JoshMeredith
Copy link
Contributor Author

Added a conclusion rewording

@hsyl20
Copy link
Contributor

hsyl20 commented Jan 20, 2023

I've added a few changes. LGTM

@hsyl20 hsyl20 requested a review from luite January 20, 2023 13:01
<script language="javascript" src="all.js" defer></script>
```

As the JS backend still lacks support for some FFI features (foreign exports, foreign "wrapper" imports...), JavaScript codes can't easily interact with Haskell codes. It reduces the amount of advanced/interesting examples we can present for now. We'll publish new blog posts illustrating these features when they will be implemented.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if the createCallback API has been merged, if it's the case then we might link to it for people who are a bit more adventurous. Now it looks like it's more limited than it actually is.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know either. Let's keep this for a future blog post IMHO

@JoshMeredith JoshMeredith merged commit 59ac730 into master Jan 24, 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.

5 participants