Hello. When using rescript-webapi I’m getting this error:
This has type: Webapi__Fetch.readableStream
Somewhere wanted:
Webapi.ReadableStream.t (defined as Webapi__ReadableStream.t)
Shouldn’t these types be regarded as equal?
Basically I’m trying to use the “exported api” instead of “internal modules” as normally suggested and I’m wondering if this is a bug, some quirk of the system or more probably something obvious I’m missing
Well…my fear just turned real… I don’t really understand what a opaque type is :-
I’m still learning rescript and I never use interface files… I also hate all the verbose duplication…
Do you mean the resi file also needs to expose the type like the implementation file?
This type readableStream = Webapi__ReadableStream.t instead of just type readableStream?
If it’s already defined in the res file why doesn’t the resi pick it up??
The interface defines what is public, so because it’s a “phantom” type in the interface, that controls what other modules see. Said another way, being able to omit the type implementation from the .resi is a feature to hide the implementation from other modules. This enables a lot of useful behavior, like enforcing all values of that type in the codebase be constructed through a parse function that handles edge cases. (for example)
If you’re coming from a JavaScript background, this is a new concept from just the “exported” API of a module. TypeScript kind of allows this with some leaps, although I don’t think it’s very common.
Gee…this get’s exoteric way to fast for me :-
Also not having a background in IT also doesn’t help much.
I tried looking at haskell and ocaml but the syntax alone made my head spin.
Is there any “for dummies” documentation about these type theory stuff suitable for someone way too old and dumb to learn a new syntax? Any rescript repository with standard examples?
Thanks for trying to thought…
Hi…thanks.
There are lot’s of types like that in the code…since it’s something so simple I’ll let him do the PR…maybe there should be a lot more changed.
All this duplication is kind 'of a bummer though :-
Are there any ideas to streamline this in the language or is it just not worth it?