Type instantiation is excessively deep and possibly infinite
Produces error:
28 Replies
Do you know if this is a regression/when it worked?
This should be an easy one to fix at least. If it is only infinite when one side of the type is extracted, it's a bug in
distill
I'm pretty sure it worked in the past but I don't know when
Yeah I made some changes recently to distill I'll fix this right away though
Hmm there's really a whole set of narrowed inference that will fail if you infer out of a morph first which forces
constrain<X, Y>
to evaluate
This is why I originally wanted constrain
to not be a subtype of the original type but at some point it seemed like I could extract what I needed so I went with it. Once you have an intersection like string & {[constrained]: constraints}
it is not possible to get back to string without enumerating all the possible builtins I want to check for which kinda sucksWhat would an alternative way be?
Just have the constrained types be a tuple or something like
[base, "constrain", constrained]
But then they couldn't be used directly
Not that they ever really are at the moment
Morph types already work that way- they can't be used directly to represent the actual dataSo right now it's more of future-proofing?
Well for now the branded types are always assignable to the base type
I will keep it that way, I found some nonsense I can do to work around it
Since obviously that is ideal
But there's not really a builtin API for actually using the branded output types by default yet
Maybe would be a global config at some point so you can choose if you want branded types
But having the information encoded in the type opens up a lot of other possibilities also. The original reason I added it was to support pattern matching
What do you mean by nonsense and how come it's ideal if it's nonsense?
Because the external inference is ideal, but internally it requires a lot of hoop-jumping
I see!
You're jumping all the hoops so that we have ideal inference 🤗
Well that is essentially the entire premise of arktype 😛
And man is the inference ideal
Well I'm fixing some cases where it was not now haha
Also I really like the new
type.infer
syntax
What is the reasoning behind it being capitalized in type.infer.In
and type.infer.Out
?I wish I didn't have to but
in
is a reserved keyword