Davide Bertola
11/02/2020, 8:08 AMsimon.vergauwen
11/02/2020, 8:26 AMIO
is getting deprecated, but those 3 are all the same API.simon.vergauwen
11/02/2020, 8:27 AMIO
.Davide Bertola
11/02/2020, 8:43 AMraulraja
11/02/2020, 10:22 AMDavide Bertola
11/02/2020, 10:23 AMDavide Bertola
11/02/2020, 10:23 AMraulraja
11/02/2020, 10:37 AMDavide Bertola
11/02/2020, 10:38 AMDavide Bertola
11/02/2020, 11:20 AMBob Glamm
11/02/2020, 2:58 PMfun getHomepage(url: URI): IO<Homepage>
that is pure internally (that is, does not depend on global state or mutate global state), this is a pure function that generates a "program" or an "effect" that retrieves the homepage for a site. It's possible to execute this program (with .unsafeRunSync, etc.), but it is also possible to compose this program with any other program (IO<Homepage>.flatMap(IO<B>).flatMap(IO<C>)
, etc. If we just have fun getHomepage(url: URI): Homepage
it may not be possible to compose that with other functions/programs if it depends on or mutates global state.
2. Tied into the above is the idea of whether a given function is total (that is, has defined outputs for all inputs) or not. A well-written function (URI) -> IO<Homepage>
is total: it is going to return an IO<Homepage>
no matter what URI
it is given, so it is very easy to reason about how to compose that together with other functions. A function (URI) -> Homepage
is not total - for example, it may throw an exception while retrieving the homepage - and is very difficult to reason about, relatively speaking, because everything that has to interact with it has to take into account every possible error that occurs, in addition to dealing with the returned Homepage
on success. IO
- or whatever the suspend replacement is for it - ensures totality for both the success path as well as all error paths so the program execution is well-defined for all inputs.Bob Glamm
11/02/2020, 3:00 PMDavide Bertola
11/02/2020, 4:01 PMDavide Bertola
11/02/2020, 4:04 PMDavide Bertola
11/02/2020, 4:10 PMsuspend
, so i do not get the "benefit of the compiler checking"Davide Bertola
11/02/2020, 4:10 PMsuspend
so the compiler will check "as if it had side effects"julian
11/02/2020, 4:49 PMany program is pure if you don't execute itI think there's a contradiction here. A program's purity is defined by its behavior when executed. So if what keeps it "pure" is only not executing it, it can't be pure.
Davide Bertola
11/02/2020, 4:49 PMDavide Bertola
11/02/2020, 4:49 PMjulian
11/02/2020, 4:50 PMjulian
11/02/2020, 4:50 PMjulian
11/02/2020, 4:53 PMjulian
11/02/2020, 4:54 PMjulian
11/02/2020, 4:57 PMBob Glamm
11/02/2020, 8:42 PMsuspend (URI) -> Homepage
is the same as (URI) -> IO<Homepage>
via the use of compiler plugins. Consistent usage of the suspend
function within a context (IO
, Either<L, _>
, etc.) is checked by the plugin, if I understand it correctly.Bob Glamm
11/02/2020, 8:43 PMIO
is just a thunk/suspend function. Arrow's current design just happens to eliminate the need to specify the datatype on the return value everywhere.Bob Glamm
11/02/2020, 8:43 PMF
with minimum requirements instead of IO
Bob Glamm
11/02/2020, 8:44 PMraulraja
11/02/2020, 8:58 PMraulraja
11/02/2020, 8:59 PMraulraja
11/02/2020, 9:00 PMDavide Bertola
11/02/2020, 9:00 PMDavide Bertola
11/02/2020, 9:01 PMraulraja
11/03/2020, 9:07 AMraulraja
11/03/2020, 9:13 AMraulraja
11/03/2020, 9:14 AMraulraja
11/03/2020, 9:18 AMDavide Bertola
11/03/2020, 10:12 AMraulraja
11/03/2020, 11:05 AMraulraja
11/03/2020, 11:12 AMMarko Novakovic
11/16/2020, 4:28 PMraulraja
11/16/2020, 5:52 PMMarko Novakovic
11/16/2020, 5:54 PM