Stream: beginners

Topic: how split the code in mutiple files


view this post on Zulip Vincenzo Palazzo (vincenzopalazzo) (Dec 04 2022 at 22:02):

There is any docs where I can read on how to spleet a code in mutliple file?

view this post on Zulip Luke Boswell (Dec 04 2022 at 22:12):

I'm not sure about docs, but you can split code into different modules and then just import them. I use this in my AoC where I have a Parser.roc which I import. For putting things in folders e.g. Internal, you then import them with imports [ Internal.Parser.{ Parser } ] for example.

view this post on Zulip Vincenzo Palazzo (vincenzopalazzo) (Dec 04 2022 at 22:20):

Luke Boswell said:

I'm not sure about docs, but you can split code into different modules and then just import them. I use this in my AoC where I have a Parser.roc which I import. For putting things in folders e.g. Internal, you then import them with imports [ Internal.Parser.{ Parser } ] for example.

mh! so if I had a file called cli and inside the file there is an export function caller parse, the import is like imports [cli.{parse}]

view this post on Zulip Vincenzo Palazzo (vincenzopalazzo) (Dec 04 2022 at 22:20):

?

view this post on Zulip Vincenzo Palazzo (vincenzopalazzo) (Dec 04 2022 at 22:35):

or the name of the module that I need to import need to start with an upper letter?

view this post on Zulip Brendan Hansknecht (Dec 04 2022 at 23:00):

I think uppercase might be required

view this post on Zulip Shritesh Bhattarai (Dec 08 2022 at 23:11):

Is there a way to do the opposite? Have essentially a submodule / namespace in the same file? I wanted to build a "Grid" module with specific types and functions defined within the same "08.roc" file.

view this post on Zulip Brendan Hansknecht (Dec 08 2022 at 23:44):

I don't think that is possible currently

view this post on Zulip Brendan Hansknecht (Dec 08 2022 at 23:44):

The closest you could get would be a struct with a bunch of lambdas in it.

view this post on Zulip Brendan Hansknecht (Dec 08 2022 at 23:45):

That would kinda be "namespacing", but definitely not the same


Last updated: Jul 05 2025 at 12:14 UTC