Last updated:
0 purchases
simple either
Simple Either #
Simple Either - a Dart library designed to facilitate functional programming through the
implementation of the Either monad. This package provides a structured approach
for handling two possible outcomes (typically success and failure) in a
functional paradigm.
Features #
Either Monad Implementation
Left and Right classes for handling success and failure
Getting started #
To start using the "simple_either" package, follow these steps:
Add the dependency to your project's pubspec.yaml file:
dependencies:
simple_either: ^1.0.0
copied to clipboard
Save the file and run pub get in your project directory to fetch and install the package.
Import the package into your project:
import 'package:simple_either/simple_either.dart';
copied to clipboard
Usage #
Explore the examples below to see how to use the "simple_either" package.
import 'package:simple_either/simple_either.dart';
import 'dart:async';
Either<Error, SuccessType> syncFunction() {
try {
// Do something that might throw an error
return Right(SuccessType());
} catch (e) {
return Left(Error());
}
}
Future<Either<Error, SuccessType>> asyncFunction() async {
try {
// Do something that might throw an error
return Right(SuccessType());
} catch (e) {
return Left(Error());
}
}
copied to clipboard
Additional information #
Check the GitHub repository for any additional information, issues, or
community
discussions.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.