-
Notifications
You must be signed in to change notification settings - Fork 30
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
Experiments with Type module #118
base: main
Are you sure you want to change the base?
Conversation
Thank you for exploring this. However, this is unlikely to receive attention anytime soon. As stated before, documentation in the form of docstrings is what's important right now, and we'll do an absolute minimum of changes before that's in place for all modules, doc extraction works, and the editor integration has been worked through. So, if you're interested in contributing, please focus on documentation for the foreseeable future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a significant improvement. But I also agree that it's not very time-sensitive.
src/Core__Type.res
Outdated
let toObjectUnsafe = i => i->Obj.magic | ||
let toBoolUnsafe = i => i->Obj.magic | ||
let toFloatUnsafe = i => i->Obj.magic | ||
let toBigIntUnsafe = i => i->Obj.magic | ||
let toStringUnsafe = i => i->Obj.magic | ||
let toSymbolUnsafe = i => i->Obj.magic | ||
let toFunctionUnsafe = i => i->Obj.magic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this isn't what I meant. These are now all just aliases of Obj.magic
, and wherever these are used internally you can just substitute with Obj.magic
directly.
If you want to export them, then the externals are better because the implementation won't be hidden by the interface and consequently add a function call on every use to what should be a no-op at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the problem. I looked at the javascript and there are all these wrappers and we want it to be completely compiled away. I went back to using external %identity in both the resi
and the res
because that results in less Js output. I find it very weird that the resi
file has implementation details like external
. If the resi
just says let toBoolUnsafe: 'a => bool
then this is the output...
function toBoolUnsafe(prim) {
return prim;
}
In a perfect world wouldn't you be able to only use external
in the implementation?
The Type module seemed like it could use some love. Here are some ideas and issues. This is a draft/experiment for feedback. I'm happy to clean up the Type module, add docs, etc. after getting feedback on this. Trying to be mindful of @glennsl feedback that we don't want to build full opinionated parsing here.
Classify
should be a sub-module with a singleclassify
function in ittypeof
unknown
type which should be used as output fromObject.get
classify
liketoString
andtoBool
to make it easier to extract values safely without having to write the switch statementsbigInt
Symbol.t
since we've got a type for this nowisNull
helpersclassify
checks for null objects and returnsNull
notObject
Issues and questions
Object
module. I couldn't figure out how to type it. Before it used an abstractobject
type defined just in this module.