-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add Curried/partially applied form? #10
Milestone
Comments
Merged
cf this thread |
I am now thinking overloading constructors so they don't construct is too evil. Maybe they should all have lowercase varients for that. |
Playing with some things using Logging: Warn, Info
@testset "1 composition Example" begin
constructor_form = MinLevelLogger(FileLogger("warn.log"), Warn))
curried_form = min_level_logger(Warn)(FileLogger("warn.log"))
piped_form = FileLogger("warn.log") |> min_level_logger(Warn)
@test constructor_form == curried_form == piped_form
end
@testset "2 compositions Example" begin
constructor_form = MinLevelLogger(
EarlyFilteredLogger(
log->log._module==Main,
FileLogger("warn.log"),
),
Warn
)
comp_logger1 = min_level_logger(Warn) ∘ EarlyFilteredLogger(log->log._module==Main)
comp_form = comp_logger1(FileLogger("warn.log"))
level_filter = min_level_logger(Warn)
module_filter = EarlyFilteredLogger(log->log._module==Main)
curried_form = level_filter(module_filter(FileLogger("warn.log")))
@test comp_form == constructor_form == curried_form
end |
Tee could be weirder, using Logging: Warn, Info
@testset "Tee and merge" begin
sink = FileLogger("all.log")
constructed_form = TeeLogger(
MinLevelLogger(sink, Info),
MinLevelLogger(sink, Warn),
);
curried_form = tee_logger(
min_level_logger(Warn),
min_level_logger(Warn)
)(sink)
curried_form2 = tee_logger(
min_level_logger(Warn),
min_level_logger(Warn)
)(sink, sink)
@test constructed_form == curried_form == curried_form2
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If everything that takes 2 arguments:
i.e. the Filters and the Transform
had an overload to just take the nonlogger argument,
then it might be prettier
Rather than writing:
we could write ∘
Which would pleasently drive home the compositional nature of the system.
The text was updated successfully, but these errors were encountered: