Stream: beginners

Topic: Effects


view this post on Zulip Rick Hull (Nov 17 2024 at 21:51):

I've heard Richard talk about effects on the podcast, and the most recent EYG episode goes in some depth with the EYG approach. My background is mostly in Ruby but maybe more of a fan of Elixir. I write mostly in a functional style, very comfortable with immutability, and understand pure functions and side effects. But this is really my first encounter with a language or approach that has a formal sense of Effects. What's a good starting point to learn more about Roc Effects?

view this post on Zulip Brendan Hansknecht (Nov 17 2024 at 22:21):

A lot is in flux with purity inference about to land. Maybe the purity inference talk would be the best bet currently....I guess how are you trying to understand about them (implementation, relation to platforms, just what they are, how they appear in roc code, other)?

view this post on Zulip Brendan Hansknecht (Nov 17 2024 at 22:21):

https://youtu.be/42TUAKhzlRI?si=D7pD6dGJyr_TY9BW

view this post on Zulip Rick Hull (Nov 17 2024 at 22:25):

I understand platforms are responsible for handling effects, and that seems like a nice property. perhaps related, it's a neat quirk that the platform calls into the application, like a library, which gives Roc itself the purity guarantees, but in my head while I was learning, I was assuming Roc was calling out to the platform. Mainly I'm thinking about how to reason about programs with an explicit notion of effects. my approach for the last 10 years or so, in Ruby, is to minimize side effects, minimize state (object ivars, mostly), and adhere to mostly functional paradigms. This has meant more easily testable code and easy transitions to concurrency and parallelism.

view this post on Zulip Rick Hull (Nov 17 2024 at 22:27):

So now, I'm wondering what amazing benefits will fall out of an explicit notion of effects, and how to harness the feature.

view this post on Zulip Rick Hull (Nov 17 2024 at 22:28):

I have a bunch of minimal gems / libs, and I'll probably try to port one to Roc soon as an exercise

view this post on Zulip Rick Hull (Nov 17 2024 at 22:30):

Watching now, thanks

view this post on Zulip Rick Hull (Nov 17 2024 at 22:37):

7 minutes in, Richard is describing everything I just typed :rolling_on_the_floor_laughing:

view this post on Zulip Rick Hull (Nov 17 2024 at 22:47):

side note: I've been silently hating the backslash until I heard Richard say it represents lambda. makes much more sense now

view this post on Zulip Luke Boswell (Nov 17 2024 at 23:40):

If you want to see purity inference in action, roc-ray graphics platform we've been using it there.

view this post on Zulip Rick Hull (Nov 18 2024 at 02:41):

I may have gotten confused by earlier podcasts and the EYG one. Is it fair to say, that in the current version of Roc, before purity inference, that effects were mostly encapsulated by Tasks and not a first class citizen?

view this post on Zulip Dan G Knutson (Nov 18 2024 at 02:46):

There was a version of roc where Task was a thing the platform library would export, another version of roc where Task was a language builtin used by exported platform functions, and the current version of roc, where you have platform functions that end in ! (like ruby), use => instead of -> in their type signature, and return a normal Result instead of a Task. If you're writing a platform you could still export a task-like thing yourself, but it would just be your own unique thing instead of a language thing.

view this post on Zulip Rick Hull (Nov 18 2024 at 02:48):

side note: my main technical task for today was to take down a 3-node proxmox cluster (currently doing nothing) and rebuild it with Incus. I'm pretty sure I'm going to install Arch, but I've got a ton of experience with Debian and been playing with NixOS lately. Once I've got Incus going, I want to define my containers in text (Infrastructure as code) and start running local services inside the LAN (torrent, weather, music, etc) and possibly some web stuff on the public net.

view this post on Zulip Rick Hull (Nov 18 2024 at 02:49):

Instead I got nerdsniped by the EYG podcast :rolling_on_the_floor_laughing:

view this post on Zulip Rick Hull (Nov 18 2024 at 02:51):

Dan: ok, so purity inference has landed? I just watched the video linked above

view this post on Zulip Luke Boswell (Nov 18 2024 at 02:53):

Yes - purity inference has landed. But theres only one (published?) platform that uses it currently.

view this post on Zulip Rick Hull (Nov 18 2024 at 02:53):

so, one of my gems is a Nostr relay, with Schnorr signatures and everything. I think that might be too big of a spike for my first Roc port. But hypothetically speaking, could/should I write a platform that e.g. does the schnorr signatures?

view this post on Zulip Luke Boswell (Nov 18 2024 at 02:54):

The upgrade for basic-cli is done on a branch, but we have a bug with try / return that makes it a less than ideal experience at the moment.

view this post on Zulip Rick Hull (Nov 18 2024 at 02:54):

my plan is to use basic-cli heavily. that's my wheelhouse

view this post on Zulip Luke Boswell (Nov 18 2024 at 02:55):

We have a plan for crypto primitives to be builtins, as for security reasons you really need to control the implementation. I'm not familiar with Schnorr, would that need to be secure?

view this post on Zulip Rick Hull (Nov 18 2024 at 02:56):

schnorr sigs use secp256k1 elliptic curve crypto. it's used mostly for bitcoin, but now Nostr etc

view this post on Zulip Luke Boswell (Nov 18 2024 at 02:56):

The first we implemented is sha256 in this PR but it's currently stuck on an LLVM bug

view this post on Zulip Rick Hull (Nov 18 2024 at 02:57):

I've got a mostly-pure-ruby impl, but also one that leans on libsecp256k1

view this post on Zulip Rick Hull (Nov 18 2024 at 02:57):

sha256 is used heavily by schnorr

view this post on Zulip Rick Hull (Nov 18 2024 at 02:58):

to answer your question, yes, as I understand ;)

view this post on Zulip Luke Boswell (Nov 18 2024 at 03:01):

Back in June @Matthieu Pizenberg gave a talk about implementing some crypto stuff in roc for fun. Heres the online meetup, you can see the recording and also see his talk notes.

view this post on Zulip Rick Hull (Nov 18 2024 at 03:04):

I've implemented 3DES, HMAC, and more. but not for production -- for QA use to verify and tickle prod. this was a long time ago. I would not have implemented schnorr sigs unless I had to (for Nostr), but I have some nice ruby code that closely matches the spec. long story short, not a crypto guy, and I'll probably want to use libsecp256k1 for any real work

view this post on Zulip Rick Hull (Nov 18 2024 at 03:06):

https://github.com/rickhull/schnorr_sig

view this post on Zulip Rick Hull (Nov 18 2024 at 03:17):

Luke: the google drive link? still waiting for the page to load...

view this post on Zulip Rick Hull (Nov 18 2024 at 03:22):

looking at roc-ray ... I have https://github.com/rickhull/driving_physics, which is entirely numerical / text, with no graphics. I really want to add graphics, and I was looking at DragonRuby game engine, but it's proprietary and actually requires mruby (embedded ruby), which is actually a completely different beast than the Ruby I used

view this post on Zulip Rick Hull (Nov 18 2024 at 03:23):

I think DragonRuby is mostly based on SDL. haven't looked at Raylib yet

view this post on Zulip Rick Hull (Nov 18 2024 at 03:27):

for my driving_physics lib, it is a first principles approach. for example, I have a Disk class, which is used to model wheel+tire, gears, flywheel, etc. a disk has mass, radius, width, and can calculate torque, moment, etc

view this post on Zulip Luke Boswell (Nov 18 2024 at 04:06):

In case you missed it https://lukewilliamboswell.github.io/roc-ray-ball-physics/

view this post on Zulip Luke Boswell (Nov 18 2024 at 04:06):

Rick Hull said:

Luke: the google drive link? still waiting for the page to load...

Is google docs not working?

view this post on Zulip Luke Boswell (Nov 18 2024 at 04:07):

Matthieu Pizenberg said:

roc-crypto-meetup-2024-06.pdf

view this post on Zulip Luke Boswell (Nov 18 2024 at 04:07):

Luke Boswell said:

Here is the video link for anyone who couldn't make it today. Some awesome talks, thanks again :tada:

view this post on Zulip Luke Boswell (Nov 18 2024 at 04:14):

I really want to add graphics, and I was looking at DragonRuby game engine, but it's proprietary and actually requires mruby (embedded ruby), which is actually a completely different beast than the Ruby I used

If you port you simulator over to roc you can use roc-ray :smile:

We haven't added 3D yet, but that (should be :sweat_smile:) easy to implement from here if you wanted that.

view this post on Zulip Luke Boswell (Nov 18 2024 at 04:15):

@Dan G Knutson and I have mostly been messing around with real-time multiplayer networking stuff, and support for Windows, Linux, Macos, and Web

view this post on Zulip Matthieu Pizenberg (Nov 18 2024 at 12:46):

As Luke said, these are "crypto for fun" and learning implementations that I did while following a course on fundamentals of cryptography. The github with the code https://github.com/mpizenberg/crypto-0-to-hero
It hasn’t been updated to the current Roc syntax, so these will not compile. I also agree with you @Rick Hull that any serious cryptography usage must be done with vetted implementations.

view this post on Zulip Rick Hull (Nov 18 2024 at 12:57):

Thanks for direct vid link, I'll check it out


Last updated: Jul 06 2025 at 12:14 UTC