Skip to content
This repository was archived by the owner on Aug 31, 2025. It is now read-only.
This repository was archived by the owner on Aug 31, 2025. It is now read-only.

Remove funbox.passthrough.passnone, or at least move it into maybe #2

@nmbooker

Description

@nmbooker

funbox.maybe.maybe_c(f)(val) is equivalent to funbox.passthrough.passnone(f)(val).

funbox.maybe is more general, in that it can take more functions, applying them left to right like in a pipeline. I think that the new interface of 'maybe' makes a chain of more than one or two much easier to read than nested calls to passnone.

maybe_c(f, g, h, ...)(val)

There's also an uncurried version, maybe(), which will be more convenient in the common case that you're not passing the chain of lifted functions as arguments to another higher-order function.

maybe(val, f, g, h, ...)

The only thing passnone()() can do that maybe_c()() or maybe() can't is to allow you to change the default return value for the None case:

>>> passnone(lambda x: x.upper(), default='NULL')(None)
'NULL'

That's the only thing that may make it worth keeping.

If I do keep passnone, I'll move it into maybe, but it may have a different name or interface.

If anyone currently uses passnone in this way, please comment below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions