simple_either 1.0.0 copy "simple_either: ^1.0.0" to clipboard
simple_either: ^1.0.0 copied to clipboard

A package that provides an Either type.

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:

  1. Add the dependency to your project's pubspec.yaml file:
dependencies:
  simple_either: ^1.0.0

Save the file and run pub get in your project directory to fetch and install the package.

  1. Import the package into your project:
import 'package:simple_either/simple_either.dart';

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());
    }
}

Additional information #

Check the GitHub repository for any additional information, issues, or community discussions.

2
likes
130
points
59
downloads

Publisher

unverified uploader

Weekly Downloads

A package that provides an Either type.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on simple_either