juvix icon indicating copy to clipboard operation
juvix copied to clipboard

Add applicative do notation

Open janmasrovira opened this issue 6 months ago • 0 comments

Applicative do notation is similar to monadic do notation with a few differences:

  1. Only pure expressions and bind statements are allowed. I.e., there are no let statements.
  2. Last statement must be of the form pure lastExpr. We could discuss how to handle this. Maybe the pure could be implicit.
  3. Variables bound in a bind statement are only in scope of the last expression in the block.
  4. We use a different keyword. E.g. ado.
ado {
  opt1 <- getOpt1
  opt2 <- getOpt2 -- opt1 is not in scope here
  pure Options.mk@{
    opt1;
    opt2;
  }
}

janmasrovira avatar Aug 21 '24 11:08 janmasrovira