Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: clarify the issues of monadic DSL #59

Open
doofin opened this issue Jun 14, 2023 · 0 comments
Open

docs: clarify the issues of monadic DSL #59

doofin opened this issue Jun 14, 2023 · 0 comments

Comments

@doofin
Copy link

doofin commented Jun 14, 2023

Hi, I see the readme says that the below code doesn't work

for {
  textA <- read(fileA)
  // Not a possible syntax
  if (fileA.contains("some string")) {
    textB <- read(fileB)
    _ <- write(fileC, textA + textB)
  }
} yield ()

However it seems that the code below works:

val o1 = Option(1)
val o2 = Option(1)

// condition in monadic DSL
for {
  a <- o1
  _ <- if true then o1 else o2
} yield ()

// while loop in monadic DSL
for {
  a <- o1
  _ <- Option(while (true) {})
} yield ()

so it seems that control structure is actually supported in the monadic DSL?

@doofin doofin changed the title clarify the issues of monadic DSL docs: clarify the issues of monadic DSL Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant