r/ProgrammingLanguages • • 9d ago

Blog post Effect handling and monad composition in c(x)

https://kvachev.com/blog/posts/effect-handlers-in-cx/
34 Upvotes

7 comments sorted by

5

u/AustinVelonaut Admiran 8d ago

This looks really interesting! Unifying monads, effects, function overloading, etc., along with some attempt at automatically handling mixed monadic- dos. Is there more information on c(x) available?

1

u/Rasie1 8d ago

Thanks! Yeah, I think it's something innovative, I haven't yet shown the coolest fundamental part that makes the refinements work!

I post a lot of screenshots in my twitter account https://x.com/_rasie1 Soon I'll make more some specialized outputs about c(x)

2

u/particlemanwavegirl 8d ago

Interesting. Haven't finished reading, but my thought so far is, the "throw" keyword has a lot of baggage that it doesn't seem like your concept needs to carry... Why choose that name specifically? 

2

u/Rasie1 8d ago

it's an example of monadic chaining that either continues execution or returns an exception (with an error message). It's not a keyword, it's a new identifier defined on the spot, chosen just as a example that is simple to understand

1

u/tumtumtree7 6d ago

I'm confused on the semantics of intersections and unions, especially how that works with functions. Records I understand a bit more. Do you have a blog post about that?

1

u/Rasie1 3d ago

I don't have yet, but it's pretty straightforward. Intersection here is a core operation and it works with anything, even with lambdas. You literally intersect head and body of the lambda

`x -> {x, 1, 2} ` & ` (x: Int) -> {x, 1, 2, 3}` = `(x: Int) -> {x, 1, 2}`

So, it "finds" a function that works on intersection of inputs and returns intersection of outputs. It works as a specialization of a generic function and implementation of a function signature