(shortest topic name award :grinning_face_with_smiling_eyes:)
Currently, 'x' is almost equivalent to writing 120, except that 'x'.U8 does not compile. Should I file a bug / feature request?
Do you need .U8?
I guess just forcing type?
Seems to make sense
The only thing I can think of is maybe we should be doing it this way https://github.com/roc-lang/roc/pull/9792
So U8.('x')? or maybe this being a literal will be lifted properly after this PR lands?
Oh I hadn't seen this PR, looks great! :tada:
U8.('x') looks good to me, although U8('x') would have a lower weirness cost for newcomers. And while we're at it we could replace 3.14.F64 with F64.(3.14) or F64(3.14).
I also feel like removing the . would make it feel less strange, like I prefer F64(3.14) over the current 3.14.F64
Only types and modules can be uppercase... so I don't think there could be any confusion
I assume there must have been a reason we went with the suffix though. I think it was the idea of having 12.Px or 13.Hrs etc
Maybe we could have both Px(12) and 12.Px
ha, in that PR i went back and forth on U8.(…) and U8(…). i went with the former to be consistent nominal tag/record construction syntax (Color.Red and Config.{ … }). but open to whatever
@Richard Feldman wdyt?
idk if we’ve discussed this syntax before — maybe around early days of static dispatch design. don’t recall exactly
I don't know if this has just passed me by completely but what is the Config.{...} syntax again? :sweat_smile:
Instantiating a Nominal type
Ah, I've been doing T :: [T({...})] still :sweat_smile: Thanks
heads up the above PR got merged, so nominals can be constructed explicitly as outlined above (with the dot, so MyType.(10))
I figure we could change in a follow up if we decided to support both U8(12) and 12.U8 -- rather than let that PR go stale. I also needed it for some things
I would like us to seriously consider Thing(12) over Thing.(12)
is the idea with U8(12) that the tag union would just unify with the nominal type?
like U8(12) would have the inferred type [U8(a), ..] where [a.from_numeral : _] and we let that unify with the nominal U8?
Ah so was the problem that an uppercase thing in isolation could be either a naked tag or a model/type.
Like is Red(255) a structural tag with payload or a possibly a nominal type.
Could we infer that from context somehow?
we have this for records/nominals already, where they can lift into the nominal implicitly
literals are tricker because they’re polymorphic
then numbers are also tricky, because they are themselves nominal types, so lifting into another nominal is not possible in the same way as records/tags
i’m on mobile rn, i can explain more clearly later
but tldr is this syntax is an explicit way to create a nominal type directly when the nominal type points to a different nominal type (eg Distance := U64) and “lifting” does not work
It's an initial response to seeing Thing.{ ... } syntax for instantiating a nominal type.
and also what’s currently on main has some rough edges, so this is still a little wip on the type checking side
Last updated: Jul 23 2026 at 13:15 UTC