Stream: ideas

Topic: new module header


view this post on Zulip Anton (Jul 04 2023 at 10:42):

In response to this topic.

Instead of:

module [Request, Response, req]

import Json
import Unicode as Uc
import [Req, Resp] from InternalHttp
import [CodePoint, first] from CodePoint as Cp
import foo : Str from "some-file.txt"

I would prefer

module
    exposes [
        Request, Response, req
    ]
    imports [
        Json,
        Unicode as Uc,
        InternalHttp.{ Req, Resp },
        (CodePoint as Cp).{ CodePoint, first },
        "some-file.txt" as foo : Str,
    ]

While also allowing inline import, because this looks significantly cleaner.

view this post on Zulip Richard Feldman (Jul 04 2023 at 11:19):

interesting! I generally default to "one way to do it" but maybe this is so common that it's worth it?

I'm curious what others think!

view this post on Zulip Ajai Nelson (Jul 04 2023 at 16:35):

My biggest concern with the import ... from syntax is that it seems backwards and inconsistent to me. I feel like the module name should come before its members. Also, if you don't specify the module name first, I don't think autocomplete will know where to look for members when you're first typing out the import.

view this post on Zulip Brendan Hansknecht (Jul 04 2023 at 17:00):

We always could use the Something.{ SubThing } syntax with the individual import lines.

view this post on Zulip Richard Feldman (Jul 04 2023 at 17:11):

that doesn't work well with the WIP proposal though :sweat_smile:

view this post on Zulip Richard Feldman (Jul 04 2023 at 17:15):

I had this as import Foo exposing [Bar, Baz] previously, like how Elm does it

view this post on Zulip Richard Feldman (Jul 04 2023 at 17:16):

thoughts on that?

view this post on Zulip Ajai Nelson (Jul 04 2023 at 17:16):

I'm good with that

view this post on Zulip Anton (Jul 04 2023 at 17:28):

I'd still prefer it with the imports list but the Foo exposing [Bar, Baz]part is good for me as well

view this post on Zulip Brendan Hansknecht (Jul 04 2023 at 19:25):

Personally, I am not a fan of the import list as part of the header if we also have an import statement. I prefer to have one or the other. Since the import statement specifically enables extra wanted functionality, I would argue we should only support that.

view this post on Zulip Anton (Jul 05 2023 at 09:53):

Uhu, it's a reasonable choice, I could live with it :p


Last updated: Jun 16 2026 at 16:19 UTC