Skip to content

do monad construct / for comprehension #4980

Open
@Kamirus

Description

@Kamirus

Currently we have the Option block syntax do ? { ... } to avoid pattern-matches when dealing with multiple ?T values. Currently we are lacking a similar mechanism for other types, e.g. Result.

As an extensible solution we might consider For Comprehensions and For Loops from Scala, which is a syntax sugar that translates expressions like

for {
  x <- e1;
  y <- e2
} yield f(x,y)

Into a sequence of flatMap, map, filter, forEach etc.

We already have a for-loop syntax which would synergize with this extension. For-comprehension syntax is similar to the do monad syntax, but instead of relying on the Monad type class (which we don't have ATM) it simply requires the presence of a standard operation like flatMap/map etc.


Links to related issues and resources:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions