Hey how can i start with Roc?
Hey
How can I be using Roc for first time?
Hi @João Alves, check out the getting started subsection in the README, link here.
I'm getting 404 in GitHub using this link.
most likely you're not added to the repo yet. maybe there is an outstanding invitation ?
Yep, make sure to check your email
Unitil now I only receive this email.
Screenshot-from-2022-02-19-11-46-31.png
the github interface should also show the invitation
somewhere in the top right
At the beginning of the email, it said "Invite sent" but I don't know where
My GitHub profile is: https://github.com/JADSN
Can you take a look @Richard Feldman?
just sent an invite!
maybe it was a copy/paste error on my part, because it said it was invited for the first time - sorry about that!
I'm trying to build roc for the first time. I'm on a mac, and it looks like valgrind doesn't support Monterey, or anything since about 2011. According to https://en.wikipedia.org/wiki/Darwin_%28operating_system%29 and https://valgrind.org/info/platforms.html
Is my understanding correct?
After exeucte cargo run examples/hello-world/Hello.roc
, I am getting this error: failed to run custom build command for
roc_builtins v0.1.0` do i need install some dependency?
I am running in Linux
what version of zig do you have?
@Trevor Settles yeah, sadly no valgrind for Mac. Personally I am on an M1 Mac, and I use nix for all of the dependencies. Makes installing a lot easier.
is there also nothing like valgrind for mac? like, what do you do when there is a memory leak?
gdb
Watch the program crash cause arm is restrictive about memory.
ok, fun
Yeah, haven't found a better way yet
that works for out of bounds memory access but not for leaks
Yeah, and misaligned
Folkert de Vries said:
what version of zig do you have?
Zip 3.0 (July 5th 2008)
Is it possible to make UI using Roc?
Like an alternative to elm-ui
zig
was not a typo, we need zig 0.8.1 https://ziglang.org/download/
Do I need Zig to execute Rust examples?
yes, it is used by the compiler
João Alves said:
Is it possible to make UI using Roc?
Like an alternative to elm-ui
No, the language is at an early stage of development and doesn't have anything like that yet. Most of the applications are small demo programs at this stage but we're working on it!
I've been working on trying to build roc, but this is the first project that I've tried building from source directly. I'm on a mac, and I have installed llvm v12.0.1, libxkbcommon v1.4.0, and zig v0.9.1 (through brew). I know that the docs say I should use zig version 0.8.0, but I haven't found a way to install that specific version through brew. I have been getting an error (below) that mentions zig, but I am not sure what is causing it. Is it the wrong version of zig?
➜ roc git:(trunk) cargo build
Compiling roc_builtins v0.1.0 (/Users/tws/develop/roc/compiler/builtins)
error: failed to run custom build command for `roc_builtins v0.1.0 (/Users/tws/develop/roc/compiler/builtins)`
Caused by:
process didn't exit successfully: `/Users/tws/develop/roc/target/debug/build/roc_builtins-c5ec60eda6bbac41/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
Compiling host ir to: /Users/tws/develop/roc/compiler/builtins/bitcode/builtins-host.ll
--- stderr
thread 'main' panicked at 'zig failed: ./build.zig:58:24: error: expected type 'std.build.EmitOption', found 'bool'
obj.emit_llvm_ir = true;
^
/usr/local/Cellar/zig/0.9.1/lib/zig/std/build.zig:1597:28: note: std.build.EmitOption declared here
pub const EmitOption = union(enum) {
^
', compiler/builtins/build.rs:158:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Yes, I believe we haven't yet updated some things to accommodate Zig 0.9.x
Zig 0.8.0 or 0.8.1 are required
Have you used Nix before?
Good to know that about zig. I haven't tried nix yet. I'll give that a go
Nix is an OS package manager for Linux and somewhat macOS, it's so friendly
I recommend installing it
Then, from the root directory of the roc repo, run nix-shell shell.nix
You should find yourself in a nested interactive shell with all Roc dependencies installed, ready to cargo run repl
:)
That did the trick, thanks! I'm in the roc repl!
I joined some time ago and Richard gave me access to the GitHub, but haven’t had a personal computer for a bit. I went on GitHub today to pull but i don’t seem to have access anymore. Is there something I’m missing or do I need to be re-invited?
Got the repo cloned and building! The README references an example platform for an HTTP server… am I misunderstanding what that means? Is that the wasm platform or is there one that would allow building of web apps?
@Michael Mongelli It shouldn't auto remove people, but I am sure that @Richard Feldman can send you a new invite link.
@Brian Parks I think that a few sample web server apps have been played around with in the past, but we don't yet have a web server example. The readme is just listing a potential use case.
This is a simple example of a webserver that I was messing around with a long while ago: https://github.com/rtfeldman/roc/pull/1635
@Brendan Hansknecht thanks. I’ll check that out and then tinker some… maybe with the goal of putting together a basic example…
@Brendan Hansknecht @Richard Feldman my mistake, I do have access, I was just expecting to see it in a different place on GitHub, thanks
Looks like this PR might cover the web example, but I do see why it wasn’t merged (yet). This might start getting into #contributing territory, but any objections to me starting to build a more sophisticated web framework on top of this platform (i.e. assuming that this will be reasonably API-stable)
That example is really simple and would not really be robust enough for most web use cases. I assume that for a proper web server platform, a lot more design work would need to go into the api. Especially when it comes to other types of requests. But if you have a basic enough use case, feel free to use the platform
Most likely a more sophisticated web framework would really be it's own platform
Also, it was never merged because all examples require testing and testing a webserver is more complicated. I just never got around to adding it and then started working on other things.
More or less forgot about it.
Sounds good. I’ll poke at it over the next couple days and share if I make anything interesting.
How can I get the Roc fmt to run on my code?
should just be ./roc format <path to file or folder>
or cargo run format <path to file or folder>
On that note, we may have a bug with the directory version. Looks like it might try to format all files, not just roc files...mine just failed trying to format the output executable.
That worked for me. Thank you
Is roc limited to one module per roc file, or can you have multiple modules (or namespaces?) in a single file?
A file is a module and a module is a file!
The way effects are currently implemented, functions in Roc are not pure from the host platform's point of view, are they?
I think they are, but are you referring to a specific aspect of their implementation?
I think the effects system includes platform-defined wrapper types (i.e. Task
) for apps to return, so that apps can purely specify what impure work should be done by the platform.
I'm referring to the roc_foo_fx_bar
functions. Those are obviously not pure and since the Roc applications call those functions, they therefore are also not pure, are they?
not sure what language you're most familiar with, but this is also the case in e.g. elm or haskell
we fix this by always wrapping the result of such functions in an Effect
, (or Task
/Cmd
in elm, IO
in haskell)
Ok, but AFAIK Elm or Haskell don't allow you to implement/switch out the platform. Just thought it could have been nice to have calling into Roc be pure from the platforms point of view.
it is
it just may give you an Effect
which the host then has to evaluate
so I'd just have to make your own types to do that, wouldn't I?
This doesn't work with the whole roc_fx_bar
thing, does it?
huh?
roc code is always pure. it can however build up a computation (an effect) that the host will evaluate, and that will produce side-effects
much like how in elm you make a Task
(pure) which the platform then evaluates (e.g. fire of an http request, impure)
Ok, I might be missing the part where the host is evaluating the effect. For example in examples/interactive/effects-platform/host.zig
where is the host getting and evaluating the getLine effect? Or in other words where is the host calling into roc code which returns an effect and evaluates that effect thus doing side effects?
we have roc__mainForHost_1_exposed_generic(output);
which evaluates main, giving a Effect {}
an Effect a
is a wrapper around {} -> a
which is forced by call_the_closure(output);
I see. And call_the_closure
calls roc__mainForHost_1_Fx_caller
which I assume evaluates the effect?
And so Effects combined with Effect.after
are just _one_ Effect, so roc__mainForHost_1_Fx_caller
evaluates all steps one after another without returning to the host, instead of evaluating the first effect and yielding the next Effect to be evaluated?
(beginner here) My interpretation is Roc is queuing up a chain of side effects that the platform executes. Roc main says "Queue this side effect. When it's done, call this Roc code which will queue another side effect. When that's done, call this other Roc code..."
When Roc executes the call to Stdout.line
it isn't executing println right then. It's like passing back a lambda to the platform, then the platform executes it.
roc__mainForHost_1_Fx_caller
calls the {} -> a
function. That will perform the main function, so it does sort of do all the effects at once. During this call no interaction with the platform happens.
but, the idea is that we can e.g. call that function twice, or in a loop
Last updated: Jul 05 2025 at 12:14 UTC