type : Eff
Example
Imagine writing a function which for performance or security reasons must not
touch the file system, but does output to the console and read from a cache.
This function undoubtedly calls other functions which you do not have direct
control of, or which someone else will some day modify. How can you ensure that
your function never touches the file-system? Without somethig like Eff
, you
have to rely on recursively reading the code of the functions your function
calls, communicating your expectations, and running tests, none of which will
reliably catch a filesystem access many calls below yours.
If however, your function and the functions it calls use Eff
, the compiler
will do all the checking for you.
For example,
Eff<E, B> noFilesystemAccess(A a) where e : ConsoleEff, CacheEff; Eff<E, A> func0() where e : ConsoleEff; Eff<E, A> func1() where e : ConsoleEff, FilesystemEff
if noFilesystemAccess
were written such that it transitively called
func0
, assuming no other errors it would compile because ConsoleEff
can interleave into ConsoleEff, CacheEff
. If the definition of func0
were changed to func1
, compilation would fail because FilesystemEff
cannot interleave with ConsoleEff, CacheEff
.