Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

bs.open does not convert from ReasonML #185

Closed
jfrolich opened this issue Nov 24, 2020 · 4 comments
Closed

bs.open does not convert from ReasonML #185

jfrolich opened this issue Nov 24, 2020 · 4 comments
Labels

Comments

@jfrolich
Copy link

exception Error(string);

let handlePromiseFailure =
  [@bs.open]
  (
    fun
    | Error(_) => ()
  );

Formats into

exception Error(string)

let handlePromiseFailure = x =>
  switch x {
  | Error(_) => ()
  }

The whole @bs.open is gone. I also have no idea how to express the code in the new rescript syntax.

https://rescript-lang.org/try?ext=re&code=KYDwxsAOAuCWD2A7ABAUQE7vugFAZ2nVkQHMBKAbgCgqAbYaZACwENEATegBSwFtY8wAGItYtAK7pgyALxVkyANoABAEZ4AdPEjBEAXXnIchhQDNxiE8gA+aTNhwB9MrIB8RsocpUgA

I think this is not a legacy way of handling exceptions as it has been introduced in 0.7 (https://github.com/rescript-lang/rescript-compiler/blob/master/site/docsource/Exception-handling.adoc#bsopen-type-safe-external-data-source-handling-since-170).

@IwanKaramazow
Copy link
Contributor

Sorry about this, we don't yet supported this in the new syntax.
You can leave it in the old syntax or write the code that bs.open expands to:
https://rescript-lang.org/try?code=KYDwxsAOAuCWD2A7ABAUQE7vugFAZ2nVkQHMBKAKAoBthpkALAQ0QBNaAFLAW1j2ABiTWNQCu6YMgC8yYJmzSAfBWTJYAM2QApPADpUIRLr4BhJt2oGIMBIgDy6O5GCIAakyItoOOVnRlkAG8VVWQ8AHdYaDAGZBw7ACMAK11uJhJYMB95fwAuWUMA4NDkAB80HOy-DiYAT2p4JlYAqUVkAGV4bmAq7Br6xuaQ1XKAfSVkADkkYGHkAF8Q+dlqfiC56cRZ1UWaOmQAN2ltPS4uvmBdCSTgMG9p6FH1eFE2Sj36cZkj0radXTOvH4ujATGiDF66CUIQiURijBY7GAgIuQhE4h6vmwRRC5U63RwIBaf1OPAuV2AeHg1AOPSJuKmMwm-xRwIkVJpPQARFzKDsKAFfmoSIhsLMgA

I'm currently focused on infix operators and some printer improvements, will look into this after those.

@jfrolich
Copy link
Author

Thanks!

@ryyppy
Copy link
Member

ryyppy commented Jan 8, 2021

This syntax feature might be irrelevant in the future (aka proper new promise api)

@stale
Copy link

stale bot commented May 28, 2023

The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions.

@stale stale bot added the stale label May 28, 2023
@stale stale bot closed this as completed Jun 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants