Alejandro Serrano.Mena
04/22/2025, 7:08 PMRaise https://arrow-kt.io/community/blog/2025/04/22/arrow-intellij-0-3/Emil Kantis
04/22/2025, 9:00 PMbind() inspections in the plugin break? (Using IJ 2025.1 with K2 mode, plugin 0.3)
I would've expected it to highlight that foo() is missing a bind here?Alejandro Serrano.Mena
04/23/2025, 7:36 AMx is of type Either and you can just print thatEmil Kantis
04/23/2025, 7:47 AMbind()?Alejandro Serrano.Mena
04/23/2025, 7:57 AMx afterwards. This particular example is not very representative, because string interpolation is one of those operations that "swallow" every type, regardless of the form. If you instead had tried to use x "as an `Int`"
val x = 1 + foo()
then you'd gotten an error because you're trying to use foo() not as Either, and the inspection would triggerAlejandro Serrano.Mena
04/23/2025, 9:48 AMleonhardt
04/24/2025, 3:00 PMx afterwards.
I've thought about this a lot actually since adopting raise in a few codebases. In general that's correct, but in particular when type A is Unit and you're not going to do anything with the result, it's so easy to forget to add bind. I've often wondered if some kind of IDE feedback could catch this as a likely mistake. Maybe just in the case where the return value is an Either, invoked within a raise, and you ignore it?leonhardt
04/24/2025, 3:03 PMAlejandro Serrano.Mena
04/25/2025, 7:37 AMleonhardt
04/25/2025, 7:48 AMgetOr* function, fold, etc.Alejandro Serrano.Mena
04/25/2025, 7:50 AMval x = thingThatReturnsEither() you're somehow "consuming" itleonhardt
04/25/2025, 7:56 AMAlejandro Serrano.Mena
04/25/2025, 8:03 AMRaise, because we have some specific knowledge (for example, the types that you can call bind on)leonhardt
04/25/2025, 8:08 AMleonhardt
05/22/2025, 7:55 PMAlejandro Serrano.Mena
05/22/2025, 8:00 PMleonhardt
05/22/2025, 8:01 PM