Support for built-in @type and @spec#113
Conversation
|
In theory, we also could use |
There was a problem hiding this comment.
Stability
I think it would be a good idea to move ensure_types!/apply/fetch_spec and fetch_type to a separate module, say TypeCheck.Experimental to make it even more clear that their API and internals might be subject to change.
(Side note: I still hope to release v1.0 of this library around ElixirConf EU, which is why we should be very clear which parts are and are not yet stable.)
Obviously the 'Experimental' doc sections might then be moved to the moduledoc.
Raising/non-raising
I'm not 100% certain (would love to know your opinion) but currently leaning towards also providing non-raising (error-tuple returning) versions of at least apply! to allow error-recovery without exceptions.
Please don't feel like all my comments have to be fixed right now. A lot of them need to be addressed at some point, but they might wait until after this PR is merged.
Thank you so much for all your hard work on this!
It is absolutely amazing. ❤️🔥
What about the name 'External' indicates that you can use it to work with types of modules which you do not directly have access to yourself. |
|
Changes since the last review:
|
|
A few more changes:
|
Qqwy
left a comment
There was a problem hiding this comment.
The PR is shaping up nicely! 😊
There are only some tiny nitpicks left, most of which are optional.
The complete version of #109
Adds the following public functions:
fetch_specto extract type from@specof the given function.fetch_typeto extract type from@typewith the given name.applywhich is the same asKernel.applybut also checks types (both arguments and result).ensure_typesmacro which extracts types from@specand puts it intoapply.The last one is experimental and isn't very stable. Areas for improvement:
ast_to_mfa) using only my own head and my own experiments in REPL. It might miss some corner cases, I'm not proficient with Elixir AST yet.Other than that, it should be good enough. The parser supports all types that TypeCheck does and even more. It also correctly infers all remote types in
@spec.