Ok, so I would like to get familiar with roc by tweaking the examples and make them do different stuff!
But I am a spoiled JS / Elm dev who is used to having a watch command on my files or a tool like nodemon, etc.
When I tried to tweak the examples/cli/Echo.roc
and ran cargo run ...
it still outputs the same as before. Obviously I need to rebuild it. But I know nothing about Rust and Cargo. Could I get some tips what I need to learn to write my own example / platform?
Do I need to learn Rust / Cargo, or learn Zig?
Not asking for a step by step guide but just some pointers so that I don't sit completely in the dark with trial and error :smile:
just cargo run examples/cli/Echo.roc
will rebuild it every time, then run the fresh binary
it will also rebuild the platform, if changes occured
platforms must be written in something that supports the C abi. we currently have C, rust and zig examples, but e.g. c#, python or swift would also work fine
I also really need to write some documentation for this! :sweat_smile:
@Richard Feldman
One thing I am curious about with roc:
What happens if firstName await returns an "Result err" ? How is this handled without a "try catch" ?
In JS either I use <promise>.catch or wrap things in a try catch.
But if firstName was a http request, how would this proceed? Would it just return the function right there at the error, returning some form of Result error? Or what would happen?
main : Task {} *
main =
{} <- await (Stdout.line "What's your first name???")
firstName <- await Stdin.line
{} <- await (Stdout.line "What's your last name???")
lastName <- await Stdin.line
Stdout.line "Hi, \(firstName) \(lastName)!"
you can always translate a <- f b
into f b \a ->
so it "just" works like andThen
in elm
Ah ok!
So a function that does http requests using await would have a "Result error value " return type? And just nicely sugars it?
it would return a task most likely?
Yeah sorry, I just meant something that maybe has a result but roc does not have maybe. I still I got the gist of things, I just dont not know the types yet hehe
ah, we use Result a {}
, so empty record for the "error" value
Last updated: Jul 06 2025 at 12:14 UTC