This repository was archived by the owner on Sep 1, 2020. It is now read-only.
This repository was archived by the owner on Sep 1, 2020. It is now read-only.
allow basic assignment as the preamble to a for comprehension #143
Closed
Description
When writing Free
code, one expects to be able to write entire methods as for comprehensions.
However, the for
syntax is limited such that the first line defines the type for the remainder, which means that we cannot put simple assignments in there.
e.g. I'd like to write
for {
a = pure_function
b = another_pure
c <- thing(a, b)
} yield c
but this must be written as (note the extra layer of indentation)
{
val a = pure_function
val b = another_pure
for {
c <- thing(a, b)
} yield c
}
or
for {
a <- Free.pure(pure_function)
b = another_pure // ok for subsequent assignments
c <- thing(a, b)
} yield c
It would be really good, and help support cleaner FP style code, if the code I expect to be able to write was rewritten using val
s.
This would need to be done in parser
, with care taken not to break the RangePosition
s.
Metadata
Metadata
Assignees
Labels
No labels