Created
June 28, 2021 21:03
-
-
Save thosakwe/67ca2928a58d4da1ead3fb4b46603efc to your computer and use it in GitHub Desktop.
Dart monad [WIP]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Monad<T> { | |
abstract MonadInstance<U> bind<U>(FutureOr<Monad<U>> Function(T) f); | |
abstract MonadInstance<T> wrap(T value); | |
} | |
abstract class EitherMonad<L, R> extends Monad<Either<L, R>> { | |
static EitherMonad<L, Exception> wrapTryCatch<L>(FutureOr<L> Function() f); | |
abstract EitherMonad<U, R> bindLeft(FutureOr<U> Function(L) f); | |
abstract EitherMonad<L, U> bindRight(FutureOr<U> Function(R) f); | |
} | |
class IOMonad<T> extends EitherMonad<T, IOException> { | |
// final EitherMonad<T, IOException> | |
IOMonad(); | |
} | |
main() async { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment