By default all functions of a module are exposed, is there an easy way to hide(not expose) a single function?
it's only functions associated with the type that get exposed
so if you write a normal top-level function, it's private to the module
That means I cannot have MyModule.some_private_stuff(...) but only MyModule -> some_private_stuff(...), right? That actually makes it clear when calling something if it is public or not. Maybe that is even kind of nice.
Richard Feldman said:
so if you write a normal top-level function, it's private to the module
If I add a top-level type alias with a name different from the filename is that private to the module too?
yep!
only things associated with the type are exposed
the mental model is supposed to be that you don't "expose" or "hide" things anymore
rather, import Foo imports the Foo type from Foo.roc and now you can access associated items on the Foo type as normal
and that's it
so if I'm in Foo.roc, anything I don't make an associated item on Foo can't be seen by other modules because import Foo is only concerned with the Foo type I defined
These kind of private functions are very useful to leave "unimplemented", where the platform provides the implementation. Much easier than all the splitting and duplicating we were doing with e.g. Cmd.roc and InternalCmd.roc
Last updated: Mar 20 2026 at 12:28 UTC