You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on and off with a hobby project using ReScript and keep running into problems using GenType whenever include and functors are used. Considering that there is a goal to improve GenType in the future - such as emitting .d.ts files - I want to include this general issue. I've filed lots of similar bugs in the past, and some specific problems get fixed. But for me the big picture is that it does not "just work", at all. There are always gotchas and complications. Here is my repo project.
Why am I using functors? I'm a big fan of wrapping basic types like int and string inside dedicated types like Age, DocumentTitle, PersonName, etc. And for these basic types, I want a bunch of basic utility functions that handle construction with validation, sorting, equality, and serialization. This is a perfect use for functors because it allows me to reduce code duplication. I need GenType for these wrapped types because I plan to integrate with a TypeScript project. If I can't access these core types from TypeScript then I can't use ReScript.
In the sample project, you'll see a module called Primitive which has a functor to make each specific wrapped type. And then ShortStringA, ShortStringB, ShortStringC, and ShortStringD are my attempts to actually use it. None of the example solutions works. The closest solution is ShortStringB but this requires me to hand-write a repetitive .resi file for every specific type I build. I can't seem to include the type definition and get the @genType annotations to follow through.
The documentation on all this is poor. Do the genType annotations work inside a .resi? What if they are in both the .resi and the .res files? Does it work with functors and include? I've had to do a lot of frustrating trial and error.
The text was updated successfully, but these errors were encountered:
It is true that genType does not work well at the module function level. Some of that is simply because it hasn't been implemented, and there is no valid workaround to be documented today.
My goal is very same as what you mentioned, making the genType as first-class feature. In other words, it should just work.
After the milestone, ideally, even no additional documentation is needed for the feature except only configuration.
I am working on and off with a hobby project using ReScript and keep running into problems using GenType whenever
include
andfunctors
are used. Considering that there is a goal to improve GenType in the future - such as emitting .d.ts files - I want to include this general issue. I've filed lots of similar bugs in the past, and some specific problems get fixed. But for me the big picture is that it does not "just work", at all. There are always gotchas and complications. Here is my repo project.https://github.com/jmagaram/functors
Why am I using functors? I'm a big fan of wrapping basic types like int and string inside dedicated types like Age, DocumentTitle, PersonName, etc. And for these basic types, I want a bunch of basic utility functions that handle construction with validation, sorting, equality, and serialization. This is a perfect use for functors because it allows me to reduce code duplication. I need GenType for these wrapped types because I plan to integrate with a TypeScript project. If I can't access these core types from TypeScript then I can't use ReScript.
In the sample project, you'll see a module called
Primitive
which has a functor to make each specific wrapped type. And thenShortStringA
,ShortStringB
,ShortStringC
, andShortStringD
are my attempts to actually use it. None of the example solutions works. The closest solution isShortStringB
but this requires me to hand-write a repetitive.resi
file for every specific type I build. I can't seem toinclude
the type definition and get the@genType
annotations to follow through.The documentation on all this is poor. Do the genType annotations work inside a .resi? What if they are in both the .resi and the .res files? Does it work with functors and include? I've had to do a lot of frustrating trial and error.
The text was updated successfully, but these errors were encountered: