aeruhxi
01/29/2020, 8:52 AMEither.fx() {
val (x) = someLeftValue()
10
} // Left propagates
Either.fx() {
someLeftValue()
10
} // Either.Right(10)
Jannis
01/29/2020, 8:58 AMbind
or one of its aliases !
component1()
to bind something in an fx
.
I would like it to be like haskell do-blocks where such things bind automatically but that is not quite possible afaik.
Maybe this will change with arrow-meta because this causes a lot of confusion imo.
@raulraja Can comprehensions in meta automatically bind anything that is not an assignment?
fx {
// binds
val x by action
// also binds
action
// does not bind
val x = action
}
Something along those lines? I think not binding the second thing there will be really confusing.Jannis
01/29/2020, 9:04 AMcomponent1
or if you bind something like a boolean with !
the compiler will sometimes do funny stuff with it (like trying to "optimize") and that can break comprehensions. So in those cases sticking to bind
is bestaeruhxi
01/29/2020, 9:08 AMval (_) = someLeftValue()
doesn't bind either. So, I'll stick to bind()
for now.Jannis
01/29/2020, 9:10 AMkyleg
01/29/2020, 6:47 PMraulraja
01/30/2020, 5:22 PMraulraja
01/30/2020, 5:24 PMJannis
01/30/2020, 5:32 PMfx {
// binds
val x by action
// also binds
action
// does not bind
val x = action
<...>
}
Equal to the following haskell code:
do
// binds
x <- action
// also binds
action
// does not bind
let x = action
<...>
So why would a desugaring not be possible if that works fine for do
blocks?raulraja
01/30/2020, 8:03 PMraulraja
01/30/2020, 8:04 PMJannis
01/30/2020, 8:15 PMby
- syntax? Either way binding only for effects (outside of assignments and expressions) should be doable right?raulraja
01/30/2020, 8:42 PMraulraja
01/30/2020, 8:42 PMJannis
01/30/2020, 9:07 PMYes, we can make it whatever we wantI definitly need to play around with that sometime^^
If you wanna hack on it I'll be happy to help 🙂I do, but not now or the next 1-2 weeks, too much going on, so I'll add me a reminder, thanks 🙂