Gleams use expression
It looks elegant indeed! What I don’t like with all those sugars, though, is that it makes you focus on the happy path and often leads to overall bad error handling. I’ve never been a fan of ocaml let...
View ArticleGleams use expression
An elegant way to solve the problem in rescript actually already exists, just use exceptions instead of result / option monads and use reanalyze to track exceptions statically.
View ArticleGleams use expression
While chaining promises (without async/await) there is also the focus on the happy path. Don’t know if you handle it in another way? let result = promise->then()->then()->then()->catch()...
View ArticleWeird error with module type
Although mxthevs offered a valid solution, I’d like to add a more thorough explanation because I get this question very often (especially from rescript beginners). The difference between the two...
View ArticleGleams use expression
I use pattern matching on awaits, whenever possible, if I use promises. This way I’m forced to thing / handle errors as well. let f = async x => switch await x() { | result =>...
View ArticleQ: Just so we're clear, ALL declaration of imported JS modules must be...
It would be amazing to have a tool to auto-generate the bindings from typescript definition files.
View Article@rescript/core: dependency or peerDependency?
It depends, just same as normal JS packages. Generally it should be peerDeps if you publish a library, otherwise put into dependency if you build app. More specifically, peerDeps describes...
View ArticleHow do you writing bindings today?
I do both. no problem there OCaml style modeling is still useful, so I won’t abandon it
View ArticleGentype: Typescript to Rescript types
Wasn’t able to thoroughly test it myself yet, but the ReScript branch has been merged and there is a ReScript guide: https://github.com/ocsigen/ts2ocaml/blob/main/docs/rescript.md
View ArticleCompile-step frontend frameworks and rescript
Vue integration is actually possible, since the lang attribute of <script> tag in SFC can receive anything. Therefore if we create a Vite plugin to transform ReScript files on demand, it would...
View ArticleRecently came to ReScript? Give us your thoughts on error messages!
Here’s one that just caught me off guard for like half an hour. I have a manually curried function and couldn’t understand why my pipe wasn’t working let decode = decoder => data =>...
View ArticleHow to convert record to object?
I met this problem while dealing with GraphQL + Apollo. There are multiple queries that return structurally equivalent yet nominally different types. I want to handle the these polymorphically (in...
View ArticleUnnecessarily strong type constraints with polymorphic variants (when using...
The following works (ReScript Playground): let f = v => { let x = ref(#b) x := v } let g = () => { let x = #a switch x { | #a => f(x) } } but the equivalent code using React.useState does not...
View ArticleDebug mode with rescript 11.0
Does the debug mode flag -bs-g work with rescript 11.0? I’m getting some weird errors when I use it. Fatal error: exception File "jscomp/core/js_dump.ml", line 828, characters 29-35: Assertion failed
View ArticleDebug mode with rescript 11.0
I was hoping to print a better type format in the console logs
View ArticleDebug mode with rescript 11.0
I have removed the files that were causing the errors but I still can’t get a nice type format in the console. I have enabled Custom formatters in Google Chrome devtools.
View Article