-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monadic composition #56
Conversation
} | ||
|
||
// (f <=< g) <=< h = f <=< (g <=< h) | ||
property("right-to-left Kleisli composition of monads") <- forAll { (x: Int, fa: ArrowOf<Int, Int>, fb: ArrowOf<Int, Int>, fc: ArrowOf<Int, Int>) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 100 characters or less: currently 156 characters (line_length)
Variable Name Min Length Rule Violation: Variable name should be 2 characters or more: currently 1 characters (variable_name_min_length)
Variable Name Min Length Rule Violation: Variable name should be 3 characters or more: currently 2 characters (variable_name_min_length)
Ignore these hound warnings for now. I'm not sure it's worth keeping on for this repo. I'll check this out tomorrow morning.
|
} | ||
|
||
/** | ||
like `>->`, but with the arguments flipped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add the explicit documentation here as well, and move this note down. I'd be kinda annoyed to have to look up documentation for a different operator to see what this one does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you're totally right. Done in c76a3e9.
I all for this! Should there be an operators file for composition? do we want to include that in the Runes file so everyone has access even if it's not a monadic operator? |
This is dope as hell. Love it. It does have me wishing we could break this up into submodules somehow though. It'd feel great to be able to I also think that for now, we should avoid introducing • as an operator here. Right now, Runes is really about monadic operations, and function composition (like function application) is just outside that scope. It's reasonable to think that maybe that should change, but I feel like that's a different discussion. Only other note: can you (should you?) remove the free |
} | ||
|
||
/** | ||
compose two functions that produce results in a context, from right to left, returning a result in that context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 100 characters or less: currently 111 characters (line_length)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line Length Violation: Line should be 100 characters or less: currently 111 characters (line_length)
Yeah I've wished for the same thing. I played around with trying to get umbrella frameworks to work, and embedding the subframeworks inside, but I couldn't work out how to write a valid module map for it, and I have no idea if that even can work.
Yep, I agree. 👍 This is kinda starting to get into overlap territory with something like https://github.com/robrix/Prelude, which defines
I didn't think there was any need for both (seeing as the free function wasn't being used anymore). Taken care of here. |
Merged as 42fbd8f Thanks! |
✨ |
Monadic composition
Here's how I'm using this with Result and RAC:
Basically, this really helps to avoid explicit closures everywhere, which I value for both readability and the avoidance of capturing strong references to
self
.The composition operator
In the example above I'm using
•
as the composition operator (which can be typed on US keyboards with Opt-8). I threw this into the specs for this PR, because I think it really helps their clarity.I'd love your feedback on: