A toolkit for writing software in dart
Includes:
ZIO
a building block for writing effectful programs. Explore the full API: https://pub.dev/documentation/elemental/latest/elemental/ZIO-class.htmlLayer
for composing dependenciesnucleus
, a simple state and dependency management tool. See more here: https://pub.dev/packages/nucleusfpdart
package https://pub.dev/packages/fpdart:
Option
Either
The ZIO<R, E, A>
type represents an synchronous or asynchronous operation.
R
generic is for representing the requirements / environmentE
generic is for representing errorsA
generic is for the success typeThere are a handful of helpful methods to ease composition!
import 'package:elemental/elemental.dart';
ZIO<NoEnv, Never, String> greeting(String name) => ZIO(() => "Hello $name!")
// Note `ZIO<NoEnv, Never, String>` can be shortened to `IO<String>`.
// Here we create a simple wrapper around `print`
IO<Unit> log(String message) => IO(() => print(message)).asUnit;
// And compose them together!
greeting.tap(log).run();
It is worth noting that the above will run synchronously. Only when you start
using Future
's in your program, will things run asynchronously.
A quick intro to services and layers can be found in example/
.