Stream: beginners

Topic: streaming a roc cli dev session


view this post on Zulip Georges Boris (Sep 06 2022 at 11:57):

Hey folks -

I have this idea of creating a simple cli application. It is supposed to be a pair of elm-book (a documentation/styleguide library for elm apps). I was wondering if I should do it with Haskell, Rust... pretty much as a learning exercise for me. tbh I'm just waiting until I can use Roc for things and I wondered if I couldn't already do so?

Maybe a pairing session between me (experienced elm developer and complete Roc beginner) with someone who knows Roc would be an entertaining thing even there are a lot of "Roc is still WIP" announcements around it. What do you think? And would someone be interested in pairing up with me?

The scope is quite simple: read text files, do pattern matching on them, read more text files, write some text files. done.

view this post on Zulip jan kili (Sep 06 2022 at 12:05):

I recommend Roc for this, and I'd love to pair with you on it! Are you available for a synchronous video meeting some weekday this week between and ?

view this post on Zulip jan kili (Sep 06 2022 at 12:06):

If not, I'm also semi-available between and

view this post on Zulip jan kili (Sep 06 2022 at 12:08):

Anyone else who wants to join is welcome! :smiley: (to learn about v0.0 Roc app development and/or contribute to the app)

view this post on Zulip Georges Boris (Sep 06 2022 at 12:13):

@JanCVanB awesome! Would you be available some time next week? I think it would be better if I actually wrote down the specs and prepare my local environment before we dive into it so our session is more productive! :) also - if you could give me a direction on the ideal local setup that would help me a lot! (I'm on macOS)

view this post on Zulip jan kili (Sep 06 2022 at 12:16):

Yes! When in those time-of-day windows next week works for you?

view this post on Zulip Georges Boris (Sep 06 2022 at 12:20):

any time between would be ideal!

view this post on Zulip jan kili (Sep 06 2022 at 12:22):

Specs & setup this week sounds good. I recommend following the installation guide and getting app #1 in here running. (Nothing special about that app, just that it's a Roc app outside the Roc repo, like yours will be)

view this post on Zulip Georges Boris (Sep 06 2022 at 12:23):

awesome! I'll set things up and confirm things with you along this week! thanks so much! it will be fun :)

view this post on Zulip jan kili (Sep 06 2022 at 12:24):

Let's plan for - for our first session!

view this post on Zulip jan kili (Sep 06 2022 at 12:25):

Any other Roc learners want to join to start an app of their own?

view this post on Zulip jan kili (Sep 06 2022 at 12:25):

Any other Roc veterans want to join to supplement my knowledge?

view this post on Zulip Georges Boris (Sep 06 2022 at 12:26):

(if you don't mind, I'll also talk about it on a few Elm chats to see if anyone wants to watch it! I'm sure there will be a few)

view this post on Zulip jan kili (Sep 06 2022 at 12:27):

(to that end, I'm happy to record it and post it on YouTube afterward, if you want)

view this post on Zulip jan kili (Sep 06 2022 at 12:29):

(but maybe advertising that fact is unnecessary, since we'd prefer synchronous company! :laughing: )

view this post on Zulip Georges Boris (Sep 06 2022 at 12:31):

that would be great!

view this post on Zulip Benjamin Thomas (Sep 06 2022 at 21:23):

Hey guys, I'd love to see this on YouTube if you have the time to set that up ;)

Remember that recording rule though, make that font BIG :grinning_face_with_smiling_eyes:

@JanCVanB

view this post on Zulip Brendan Hansknecht (Sep 06 2022 at 23:28):

Sounds like a fun project. I'm always willing to give advice and help with roc stuff, especially platforms. I tend to mess with them pretty often.

view this post on Zulip David Dunn (Sep 09 2022 at 08:09):

Keen! See you all then :big_smile:

view this post on Zulip jan kili (Sep 13 2022 at 00:20):

Anyone who's interested in an introduction to Roc app development, join us at ! :smiley:
@Georges Boris @Ralf Engbers @doubledup @Brendan Hansknecht
I'll post a video chat link in here before then.
If you can't join live, we'll have some kind of recording of it on YouTube later this week.

view this post on Zulip jan kili (Sep 13 2022 at 13:50):

Here's the link for the party at , feel free to share it around! https://meet.jit.si/AppDevelopmentWithRoc
@Georges Boris @Ralf Engbers @doubledup @Brendan Hansknecht @Brian Carroll @Ghislain @Richard Feldman

view this post on Zulip Georges Boris (Sep 13 2022 at 14:45):

hey folks! I'm trying to compile Roc from source for this session (I've previously done it using nix)

view this post on Zulip Georges Boris (Sep 13 2022 at 14:45):

but just using cargo compile --release is giving me unsuitable llvm errors

view this post on Zulip Georges Boris (Sep 13 2022 at 14:45):

what version should I be trying to install using llvmenv? (running macOS - not M1)

view this post on Zulip Ayaz Hafiz (Sep 13 2022 at 14:47):

LLVM 13 is needed

view this post on Zulip jan kili (Sep 13 2022 at 14:48):

@Georges Boris if that fails, I can send you my macOS x86 build (rebuilding right now)

view this post on Zulip Brendan Hansknecht (Sep 13 2022 at 14:53):

So this time you are trying to build roc from source while manually installing packages instead of using the nix development environment? why?

view this post on Zulip Anton (Sep 13 2022 at 14:53):

We also have a macos x86_64 nightly release

view this post on Zulip Georges Boris (Sep 13 2022 at 14:54):

@JanCVanB worked on a few features last night that are not yet in the nightly build! So I'm building from source.

view this post on Zulip Georges Boris (Sep 13 2022 at 14:54):

and I'm not using nix to do it just because I haven't found the docs about it on the repo anymore :sweat_smile:

view this post on Zulip Anton (Sep 13 2022 at 14:55):

Docs for using nix

view this post on Zulip Anton (Sep 13 2022 at 14:56):

You will also need to insall zig 0.9.1 if you don't want to use nix

view this post on Zulip jan kili (Sep 13 2022 at 16:19):

Thanks, everyone, for attending! That was fun, let's do it again sometime :smiley:

view this post on Zulip jan kili (Sep 13 2022 at 16:19):

I think that counted as a "meetup"...

view this post on Zulip Georges Boris (Sep 13 2022 at 16:19):

It sure was! Hopefully it will get more people excited about trying out Roc right now instead of waiting :)

view this post on Zulip jan kili (Sep 13 2022 at 16:20):

Here's where we got, for anyone who missed it:

app "elm_book_mimic"
    packages { pf: "roc/examples/interactive/cli-platform/main.roc" }
    imports [pf.Stdout, pf.Stderr, pf.Task, pf.File, pf.Path]
    provides [main] to pf

main : Task.Task {} [] [Write [File, Stdout, Stderr], Read [File], Env]
main =
    templateFile = Path.fromStr "template.txt"
    contentFile = Path.fromStr "content.txt"
    renderFile = Path.fromStr "render.txt"
    task =
        template <- File.readUtf8 templateFile |> Task.await
        content <- File.readUtf8 contentFile |> Task.await
        { before, after } =
            Str.splitFirst template "content goes here!\n"
                |> Result.withDefault { before: template, after: "" }
        render = "\(before)\(content)\(after)"
        File.writeUtf8 renderFile render

    Task.attempt task \result ->
        when result is
            Err (FileWriteErr _ PermissionDenied) -> Stderr.line "Err: PermissionDenied"
            Err (FileWriteErr _ Unsupported) -> Stderr.line "Err: Unsupported"
            Err (FileWriteErr _ (Unrecognized _ other)) -> Stderr.line "Err: \(other)"
            Err (FileReadErr _ _) -> Stderr.line "Error reading file"
            Err _ -> Stderr.line "Uh oh, there was an error!"
            Ok _ -> Stdout.line "Successfully rendered!"
jan@mackey app_development_with_roc % cat template.txt
text text text

content goes here!

other text other text
jan@mackey app_development_with_roc % cat content.txt
I AM THE CONTENT
jan@mackey app_development_with_roc % cat render.txt
text text text

I AM THE CONTENT

other text other text
jan@mackey app_development_with_roc %

view this post on Zulip Georges Boris (Sep 13 2022 at 16:20):

@JanCVanB are you going to publish it on youtube? I'm up for sharing the video in a few places when it have it ready

view this post on Zulip jan kili (Sep 13 2022 at 16:26):

Will publish this week! Might try to do some audio cleanup...

view this post on Zulip jan kili (Sep 13 2022 at 16:27):

I couldn't help but refactor that app a bit, here's where I've gotten so far, to make it more Roc-y in my eyes:

app "elm_book_mimic"
    packages { pf: "roc/examples/interactive/cli-platform/main.roc" }
    imports [pf.Stdout, pf.Stderr, pf.Task, pf.File, pf.Path]
    provides [main] to pf

main = Task.attempt steps handleResult

steps =
    template <- read "template.txt" |> Task.await
    content <- read "content.txt" |> Task.await
    { before, after } = split template "content goes here!\n"
    write "render.txt" "\(before)\(content)\(after)"

read = \path -> path |> Path.fromStr |> File.readUtf8
write = \path, text -> path |> Path.fromStr |> File.writeUtf8 text
split = \text, splitPoint ->
    text
        |> Str.splitFirst splitPoint
        |> Result.withDefault { before: text, after: "" }

handleResult = \result ->
    when result is
        Err (FileWriteErr _ PermissionDenied) -> Stderr.line "Err: PermissionDenied"
        Err (FileWriteErr _ Unsupported) -> Stderr.line "Err: Unsupported"
        Err (FileWriteErr _ (Unrecognized _ other)) -> Stderr.line "Err: \(other)"
        Err (FileReadErr _ _) -> Stderr.line "Error reading file"
        Err _ -> Stderr.line "Uh oh, there was an error!"
        Ok _ -> Stdout.line "Successfully rendered!"

view this post on Zulip jan kili (Sep 13 2022 at 16:28):

I truly do love the |> operator... :heart_eyes:

view this post on Zulip Anton (Sep 13 2022 at 17:05):

A nice demonstration of backpassing as well :)

view this post on Zulip Georges Boris (Sep 13 2022 at 19:04):

folks - is the platform we used for the session supposed to be available in the current nightly release for mac os? I've downloaded the last two builds and there is only "hello-world" in the examples folder:

https://github.com/roc-lang/roc/releases

view this post on Zulip jan kili (Sep 13 2022 at 20:07):

No, the releases only contain the hello world platform - you need to clone the roc repo to get the other examples, one of which is what we used

view this post on Zulip jan kili (Sep 13 2022 at 20:08):

However, perhaps now/soon we should bundle the example CLI platform with the releases!

view this post on Zulip jan kili (Sep 13 2022 at 20:09):

Eventually it won't be necessary, when any published platform is available as a remote package via package manager

view this post on Zulip Richard Feldman (Sep 13 2022 at 20:45):

I actually think it's probably better for now to encourage people to clone the repo to get the CLI platform, since it's being actively updated; otherwise you'll probably get the one version you downloaded with whenever you happened to get Nightly, and won't have the convenient git pull to update it

view this post on Zulip Brendan Hansknecht (Sep 13 2022 at 21:14):

If they aren't building from source they may have to update their version of the compiler anyway to support newer versions of the platform.

view this post on Zulip jan kili (Sep 13 2022 at 21:15):

Interesting

view this post on Zulip Richard Feldman (Sep 13 2022 at 22:24):

true!

view this post on Zulip Georges Boris (Sep 14 2022 at 11:45):

got it! so - I know this is getting off-topic but just so we can finish the thread: when building from source via cargo build --release where would I find the build result similar to what one would see on nightly builds?

view this post on Zulip Anton (Sep 14 2022 at 11:47):

the roc binary would be in the folder target/release/
If you move the roc binary somewhere else, you should also copy along the lib folder (also in target/release/)


Last updated: Jul 05 2025 at 12:14 UTC