Skip to content

expected: map([...] (...) -> expected<...> { ... }) produces expected<expected> #41

@ArsenArsen

Description

@ArsenArsen

While this behavior is probably fine, it would be desirable to be able to chain expecteds for monadic operations.

For an example of such see Haskell's Either

-- Module      :  Data.Either
-- Copyright   :  (c) The University of Glasgow 2001
-- License     :  BSD-style (see the file libraries/base/LICENSE)

-- | @since 4.4.0.0
instance Monad (Either e) where
    Left  l >>= _ = Left l
    Right r >>= k = k r

In essence, this means that >>= propagates error and does not evaluate k (type: a -> Either e b) unless the Either is a Right (success case)

EDIT: similarly, there's no way to implicitly convert to a different expected result of same error (one would have to do if (!e) { {co_}return e.error(); })

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