Stream: beginners

Topic: Optional fields


view this post on Zulip 947R3K (Jan 09 2026 at 23:28):

How do they work? I'd like to write code like:

MyType: { disabled ? Bool }
my_list: List MyType
my_list = [{}, {disabled: Bool.true}]

List.map my_list |{disabled ?? False}|
    #...

However, the compiler does not see {} and {disabled: Bool.true} as both conforming to MyType. The error message says "find out more at TODO"

view this post on Zulip Brendan Hansknecht (Jan 10 2026 at 00:56):

That feature is actually being removed in the new compiler, so may not be worth worrying about.

view this post on Zulip Brendan Hansknecht (Jan 10 2026 at 00:56):

I think that it should be this though:

MyType: { disabled ? Bool }
my_list: List MyType
my_list = [{}, {disabled: Bool.true}]

List.map my_list |{disabled ? Bool.False}|
    #...

view this post on Zulip 947R3K (Jan 10 2026 at 01:30):

So in the new compiler, will there be any way to say that a record field is
optional?

view this post on Zulip Brendan Hansknecht (Jan 10 2026 at 03:37):

As of current there is no planned feature to replace it.

view this post on Zulip Brendan Hansknecht (Jan 10 2026 at 03:40):

builder pattern is a common alternative

view this post on Zulip 947R3K (Jan 10 2026 at 03:42):

ok, thanks!

view this post on Zulip Artem (Jan 10 2026 at 17:03):

I think the paradigm used for languages like Roc implies using some kind of an option type and a function that gets default value when it's not set


Last updated: Jan 12 2026 at 12:19 UTC