Skip to content
This repository was archived by the owner on May 29, 2023. It is now read-only.
This repository was archived by the owner on May 29, 2023. It is now read-only.

Support conversion to Either #9

@shadowhand

Description

@shadowhand

Would it make sense to have a Maybe::toEither(): Either method?

abstract class Maybe
{
    // ...
    public function toEither(): Either
    {
        return $this->map('\PhpFp\Either\Either::of')->fork(Either::left(null));
    }
}

Or perhaps it would be better to have abstract public function toEither(): Either implemented as:

// Just
public function toEither(): Either
{
    return Either::of($this->value);
}

// Nothing
public function toEither(): Either
{
    return Either::left(null);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions