Skip to content

Kleisli#andThen unavailable for functor Validated[X, ?] #2013

Description

@andyscott

Composing Kleisli's with andThen isn't possible when the functor is Validated[X, ?] even though validated has an andThen method.

This is because Kleisli's andThen is an alias for flatMap and requires a FlatMap instance but Validated doesn't have a FlatMap instance (rightly so).

I don't know if it's reasonable, but there could be an AndThen type class in the same manner as FlatMap. The laws could be the same and for the vast majority of the instances the andThen method would just alias to flatMap. A default internal AndThenIsFlatMap trait could bake this into existing FlatMap instances. I don't know if this has any broader benefit outside of fixing the issue described above.

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