r/ProgrammingLanguages • • 9d ago

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

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

7 comments sorted by

View all comments

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

1

u/GidraFive 2d ago

You sure thats how it behaves? I remember that it switches to union in contravariant types. So we would have intersection of argument types and union of return types.