Hi. I need your help I try to use arrow in pure st...
# arrow
a
Hi. I need your help I try to use arrow in pure style. I created FileSystem that containt methods for forking with FS. It generic by T, whete T is container for result value for all methods. Next i want create method, that accept my FileSystem object and do smth with fs. But i want use do-notation and discribe, that my method accept only
FileSystem m
where m is any monad type. How can i do this?
r
Hi Alexander, do you have some code or gist of what you are trying to do?
a
Copy code
interface FileSystem<T> {
    fun writeFile(path: Path, text: String): Kind<T, Unit>
}

fun <T>doSomeWork(FS: FileSystem<T>, ...): Kind<T, Unit> = fx.monad {
    ...
    unit.just()
}
smth like this with restriction in doSomeFsWork that
T
must be monad
for using fx.monad
p
cool
you can couple your FileSystem with monad or not
if you do
interface FileSystem<T>: MonadFx<T>
otherwise
Copy code
fun <T> doSomeWork(FS: FileSystem<T>, MX: MonadFx<T>): Kind<T, Unit> = MX.fx.monad { ...; MX.unit() }
if you want to be cute you can use extension functions
Copy code
fun <T> MonadFx<T>.doSomeWork(FS: FileSystem<T>): Kind<T, Unit> = fx.monad { ...; unit() }
a
in second and third variant how I must call this func in other fx syntax