Stream: ideas

Topic: 'x'.U8


view this post on Zulip Aurélien Geron (Jun 25 2026 at 03:03):

(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?

view this post on Zulip Brendan Hansknecht (Jun 25 2026 at 03:45):

Do you need .U8?

view this post on Zulip Brendan Hansknecht (Jun 25 2026 at 03:46):

I guess just forcing type?

view this post on Zulip Brendan Hansknecht (Jun 25 2026 at 03:46):

Seems to make sense

view this post on Zulip Luke Boswell (Jun 25 2026 at 03:47):

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?

view this post on Zulip Aurélien Geron (Jun 25 2026 at 04:34):

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).

view this post on Zulip Luke Boswell (Jun 25 2026 at 04:49):

I also feel like removing the . would make it feel less strange, like I prefer F64(3.14) over the current 3.14.F64

view this post on Zulip Luke Boswell (Jun 25 2026 at 04:49):

Only types and modules can be uppercase... so I don't think there could be any confusion

view this post on Zulip Luke Boswell (Jun 25 2026 at 04:50):

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

view this post on Zulip Aurélien Geron (Jun 25 2026 at 04:57):

Maybe we could have both Px(12) and 12.Px

view this post on Zulip Jared Ramirez (Jun 25 2026 at 05:36):

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

view this post on Zulip Jonathan (Jun 25 2026 at 08:34):

I don't know if this has just passed me by completely but what is the Config.{...} syntax again? :sweat_smile:

view this post on Zulip Luke Boswell (Jun 25 2026 at 08:37):

Instantiating a Nominal type

view this post on Zulip Jonathan (Jun 25 2026 at 09:21):

Ah, I've been doing T :: [T({...})] still :sweat_smile: Thanks

view this post on Zulip Jared Ramirez (Jun 27 2026 at 01:06):

heads up the above PR got merged, so nominals can be constructed explicitly as outlined above (with the dot, so MyType.(10))

view this post on Zulip Luke Boswell (Jun 27 2026 at 01:15):

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

view this post on Zulip Luke Boswell (Jun 27 2026 at 01:16):

I would like us to seriously consider Thing(12) over Thing.(12)

view this post on Zulip Richard Feldman (Jun 27 2026 at 01:30):

is the idea with U8(12) that the tag union would just unify with the nominal type?

view this post on Zulip Richard Feldman (Jun 27 2026 at 01:31):

like U8(12) would have the inferred type [U8(a), ..] where [a.from_numeral : _] and we let that unify with the nominal U8?

view this post on Zulip Luke Boswell (Jun 27 2026 at 02:25):

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?

view this post on Zulip Jared Ramirez (Jun 27 2026 at 02:29):

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

view this post on Zulip Jared Ramirez (Jun 27 2026 at 02:30):

i’m on mobile rn, i can explain more clearly later

view this post on Zulip Jared Ramirez (Jun 27 2026 at 02:31):

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

view this post on Zulip Luke Boswell (Jun 27 2026 at 02:32):

It's an initial response to seeing Thing.{ ... } syntax for instantiating a nominal type.

view this post on Zulip Jared Ramirez (Jun 27 2026 at 02:33):

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