Stream: ideas

Topic: Argument order for basic-cli file writing functions


view this post on Zulip Isaac Van Doren (Nov 17 2024 at 18:54):

There have been several times where I've tried to write something like this

myFileContent |> File.writeBytes! "/some/path"

and been very surprised that I actually needed to write this

 File.writeBytes! "/some/path" myFileContent

In the File module my initial assumption is that the file content is the important data structure that is the first argument to the functions, not the file path. I frequently want to build up the file content in a pipeline, but never the path, so it seems very unergonomic.

Because of this, I think we should change the file writing functions to accept the file content as the first argument. Thoughts?

view this post on Zulip Sam Mohr (Nov 17 2024 at 18:56):

Absolutely a good idea, I've noticed the same thing

view this post on Zulip Richard Feldman (Nov 17 2024 at 19:46):

fine by me!

view this post on Zulip Isaac Van Doren (Nov 18 2024 at 02:56):

Great!
PRs for basic-cli and basic-webserver:
https://github.com/roc-lang/basic-cli/pull/267
https://github.com/roc-lang/basic-webserver/pull/78

view this post on Zulip Isaac Van Doren (Nov 18 2024 at 02:56):

(deleted)


Last updated: Jun 16 2026 at 16:19 UTC