Stream: ideas

Topic: Partial module params


view this post on Zulip Kilian Vounckx (Jan 01 2025 at 14:36):

I was wondering if this is supported, planned or neither. Suppose I want to import a module Foo:

module {
    given_foo,
    given_bar,
} -> [
    gotten_foo,
    gotten_bar,
    gotten_baz,
]

gotten_foo = \x -> given_foo x 1
gotten_bar = \x -> given_bar x 1
gotten_baz = \x -> x + 1

However, I only want to use the gotten_foo function. Is there a need to provide the given_bar function?

Or even more extremely, why would I need to provide module params at all if I only want to use gotten_baz?

view this post on Zulip Brendan Hansknecht (Jan 01 2025 at 15:08):

I don't think that is planned. If you need those split up for more granular use, they should be in different modules

view this post on Zulip Brendan Hansknecht (Jan 01 2025 at 15:09):

Module params are the contract of the module. Even if you only use a small portion of the functions, you have to fill the full contract.

view this post on Zulip Brendan Hansknecht (Jan 01 2025 at 15:10):

Also, allowing partial imports would mean that it is a breaking change for the module author to call given_bar in gotten_baz.

view this post on Zulip Brendan Hansknecht (Jan 01 2025 at 15:11):

That seems like it would make the package ecosystem much more painful. Way more things would become breaking changes.

view this post on Zulip Brendan Hansknecht (Jan 01 2025 at 15:12):

Of course if you want to do the equivalent of a partial import, you can just make all other functions call crash

view this post on Zulip Kilian Vounckx (Jan 01 2025 at 20:35):

Brendan Hansknecht said:

Also, allowing partial imports would mean that it is a breaking change for the module author to call given_bar in gotten_baz.

Did not think of this!

view this post on Zulip Kilian Vounckx (Jan 01 2025 at 20:36):

Anyway, thanks for the reply. It makes sense after hearing your points


Last updated: Jun 16 2026 at 16:19 UTC