Stream: beginners

Topic: getting started


view this post on Zulip João Alves (Feb 19 2022 at 14:27):

Hey how can i start with Roc?

view this post on Zulip João Alves (Feb 19 2022 at 14:27):

Hey

view this post on Zulip João Alves (Feb 19 2022 at 14:28):

How can I be using Roc for first time?

view this post on Zulip Anton (Feb 19 2022 at 14:39):

Hi @João Alves, check out the getting started subsection in the README, link here.

view this post on Zulip João Alves (Feb 19 2022 at 14:39):

I'm getting 404 in GitHub using this link.

view this post on Zulip Folkert de Vries (Feb 19 2022 at 14:40):

most likely you're not added to the repo yet. maybe there is an outstanding invitation ?

view this post on Zulip Anton (Feb 19 2022 at 14:41):

Yep, make sure to check your email

view this post on Zulip João Alves (Feb 19 2022 at 14:47):

Unitil now I only receive this email.

Screenshot-from-2022-02-19-11-46-31.png

view this post on Zulip Folkert de Vries (Feb 19 2022 at 14:48):

the github interface should also show the invitation

view this post on Zulip Folkert de Vries (Feb 19 2022 at 14:48):

somewhere in the top right

view this post on Zulip João Alves (Feb 19 2022 at 15:03):

At the beginning of the email, it said "Invite sent" but I don't know where

view this post on Zulip João Alves (Feb 19 2022 at 15:04):

My GitHub profile is: https://github.com/JADSN

view this post on Zulip Anton (Feb 19 2022 at 15:49):

Can you take a look @Richard Feldman?

view this post on Zulip Richard Feldman (Feb 19 2022 at 15:55):

just sent an invite!

view this post on Zulip Richard Feldman (Feb 19 2022 at 15:56):

maybe it was a copy/paste error on my part, because it said it was invited for the first time - sorry about that!

view this post on Zulip Trevor Settles (Feb 19 2022 at 16:12):

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?

view this post on Zulip João Alves (Feb 19 2022 at 17:03):

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?

view this post on Zulip João Alves (Feb 19 2022 at 17:04):

I am running in Linux

view this post on Zulip Folkert de Vries (Feb 19 2022 at 17:12):

what version of zig do you have?

view this post on Zulip Brendan Hansknecht (Feb 19 2022 at 17:26):

@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.

view this post on Zulip Folkert de Vries (Feb 19 2022 at 17:32):

is there also nothing like valgrind for mac? like, what do you do when there is a memory leak?

view this post on Zulip Brendan Hansknecht (Feb 19 2022 at 17:39):

gdb

view this post on Zulip Brendan Hansknecht (Feb 19 2022 at 17:39):

Watch the program crash cause arm is restrictive about memory.

view this post on Zulip Folkert de Vries (Feb 19 2022 at 17:42):

ok, fun

view this post on Zulip Brendan Hansknecht (Feb 19 2022 at 17:43):

Yeah, haven't found a better way yet

view this post on Zulip Folkert de Vries (Feb 19 2022 at 17:43):

that works for out of bounds memory access but not for leaks

view this post on Zulip Brendan Hansknecht (Feb 19 2022 at 17:44):

Yeah, and misaligned

view this post on Zulip João Alves (Feb 20 2022 at 11:35):

Folkert de Vries said:

what version of zig do you have?

Zip 3.0 (July 5th 2008)

view this post on Zulip João Alves (Feb 20 2022 at 11:36):

Is it possible to make UI using Roc?

view this post on Zulip João Alves (Feb 20 2022 at 11:37):

Like an alternative to elm-ui

view this post on Zulip Folkert de Vries (Feb 20 2022 at 11:37):

zig was not a typo, we need zig 0.8.1 https://ziglang.org/download/

view this post on Zulip João Alves (Feb 20 2022 at 11:44):

Do I need Zig to execute Rust examples?

view this post on Zulip Folkert de Vries (Feb 20 2022 at 11:49):

yes, it is used by the compiler

view this post on Zulip Brian Carroll (Feb 20 2022 at 13:21):

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!

view this post on Zulip Trevor Settles (Feb 26 2022 at 04:41):

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

view this post on Zulip jan kili (Feb 26 2022 at 04:42):

Yes, I believe we haven't yet updated some things to accommodate Zig 0.9.x

view this post on Zulip jan kili (Feb 26 2022 at 04:42):

Zig 0.8.0 or 0.8.1 are required

view this post on Zulip jan kili (Feb 26 2022 at 04:43):

Have you used Nix before?

view this post on Zulip Trevor Settles (Feb 26 2022 at 04:45):

Good to know that about zig. I haven't tried nix yet. I'll give that a go

view this post on Zulip jan kili (Feb 26 2022 at 04:45):

Nix is an OS package manager for Linux and somewhat macOS, it's so friendly

view this post on Zulip jan kili (Feb 26 2022 at 04:45):

I recommend installing it

view this post on Zulip jan kili (Feb 26 2022 at 04:46):

Then, from the root directory of the roc repo, run nix-shell shell.nix

view this post on Zulip jan kili (Feb 26 2022 at 04:47):

You should find yourself in a nested interactive shell with all Roc dependencies installed, ready to cargo run repl :)

view this post on Zulip Trevor Settles (Feb 26 2022 at 04:59):

That did the trick, thanks! I'm in the roc repl!

view this post on Zulip Michael Mongelli (Mar 08 2022 at 05:38):

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?

view this post on Zulip Brian Parks (Mar 08 2022 at 05:43):

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?

view this post on Zulip Brendan Hansknecht (Mar 08 2022 at 05:47):

@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.

view this post on Zulip Brendan Hansknecht (Mar 08 2022 at 05:48):

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

view this post on Zulip Brian Parks (Mar 08 2022 at 05:50):

@Brendan Hansknecht thanks. I’ll check that out and then tinker some… maybe with the goal of putting together a basic example…

view this post on Zulip Michael Mongelli (Mar 08 2022 at 05:56):

@Brendan Hansknecht @Richard Feldman my mistake, I do have access, I was just expecting to see it in a different place on GitHub, thanks

view this post on Zulip Brian Parks (Mar 08 2022 at 06:01):

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)

view this post on Zulip Brendan Hansknecht (Mar 08 2022 at 06:07):

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

view this post on Zulip Brendan Hansknecht (Mar 08 2022 at 06:08):

Most likely a more sophisticated web framework would really be it's own platform

view this post on Zulip Brendan Hansknecht (Mar 08 2022 at 06:08):

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.

view this post on Zulip Brendan Hansknecht (Mar 08 2022 at 06:09):

More or less forgot about it.

view this post on Zulip Brian Parks (Mar 08 2022 at 06:53):

Sounds good. I’ll poke at it over the next couple days and share if I make anything interesting.

view this post on Zulip Derek Gustafson (Mar 09 2022 at 03:35):

How can I get the Roc fmt to run on my code?

view this post on Zulip Brendan Hansknecht (Mar 09 2022 at 03:40):

should just be ./roc format <path to file or folder>

view this post on Zulip Brendan Hansknecht (Mar 09 2022 at 03:40):

or cargo run format <path to file or folder>

view this post on Zulip Brendan Hansknecht (Mar 09 2022 at 03:42):

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.

view this post on Zulip Derek Gustafson (Mar 09 2022 at 03:55):

That worked for me. Thank you

view this post on Zulip Jared Cone (Mar 10 2022 at 19:40):

Is roc limited to one module per roc file, or can you have multiple modules (or namespaces?) in a single file?

view this post on Zulip Brian Carroll (Mar 10 2022 at 22:42):

A file is a module and a module is a file!

view this post on Zulip Tom Dohrmann (Mar 11 2022 at 11:26):

The way effects are currently implemented, functions in Roc are not pure from the host platform's point of view, are they?

view this post on Zulip jan kili (Mar 11 2022 at 13:24):

I think they are, but are you referring to a specific aspect of their implementation?

view this post on Zulip jan kili (Mar 11 2022 at 13:27):

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.

view this post on Zulip Tom Dohrmann (Mar 11 2022 at 13:30):

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?

view this post on Zulip Folkert de Vries (Mar 11 2022 at 13:38):

not sure what language you're most familiar with, but this is also the case in e.g. elm or haskell

view this post on Zulip Folkert de Vries (Mar 11 2022 at 13:38):

we fix this by always wrapping the result of such functions in an Effect, (or Task/Cmd in elm, IO in haskell)

view this post on Zulip Tom Dohrmann (Mar 11 2022 at 13:56):

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.

view this post on Zulip Folkert de Vries (Mar 11 2022 at 13:56):

it is

view this post on Zulip Folkert de Vries (Mar 11 2022 at 13:57):

it just may give you an Effect

view this post on Zulip Folkert de Vries (Mar 11 2022 at 13:57):

which the host then has to evaluate

view this post on Zulip Tom Dohrmann (Mar 11 2022 at 14:00):

so I'd just have to make your own types to do that, wouldn't I?

view this post on Zulip Tom Dohrmann (Mar 11 2022 at 14:00):

This doesn't work with the whole roc_fx_bar thing, does it?

view this post on Zulip Folkert de Vries (Mar 11 2022 at 14:02):

huh?

view this post on Zulip Folkert de Vries (Mar 11 2022 at 14:02):

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

view this post on Zulip Folkert de Vries (Mar 11 2022 at 14:03):

much like how in elm you make a Task (pure) which the platform then evaluates (e.g. fire of an http request, impure)

view this post on Zulip Tom Dohrmann (Mar 11 2022 at 14:07):

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?

view this post on Zulip Folkert de Vries (Mar 11 2022 at 14:18):

we have roc__mainForHost_1_exposed_generic(output); which evaluates main, giving a Effect {}

view this post on Zulip Folkert de Vries (Mar 11 2022 at 14:19):

an Effect a is a wrapper around {} -> a

view this post on Zulip Folkert de Vries (Mar 11 2022 at 14:19):

which is forced by call_the_closure(output);

view this post on Zulip Tom Dohrmann (Mar 11 2022 at 14:30):

I see. And call_the_closure calls roc__mainForHost_1_Fx_caller which I assume evaluates the effect?

view this post on Zulip Tom Dohrmann (Mar 11 2022 at 14:35):

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?

view this post on Zulip Jared Cone (Mar 11 2022 at 17:19):

(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.

view this post on Zulip Folkert de Vries (Mar 11 2022 at 17:25):

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.

view this post on Zulip Folkert de Vries (Mar 11 2022 at 17:26):

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