functionally 0.0.1-dev.5 copy "functionally: ^0.0.1-dev.5" to clipboard
functionally: ^0.0.1-dev.5 copied to clipboard

A library designed to help develop code in a more FP oriented way.

This library introduces numerous pure functional types, much like fp-ts

Features #

Here are some examples of types which you may find

  • Either
  • IO
  • Task
  • Reader
  • ReaderStream
  • ...

Keep in mind that I will be adding more types as I continue development. If you need one in particular, just open an issue.

Usage #

There are two ways to use this library.

  1. A more object-oriented approach which uses builders to chain methods and build the functional types.
  2. A more functional approach which sequentially pipes functions to get a result.

Object-oriented:

import 'package:functionally/builders.dart';

void main() {
  final readerStream =
        ReaderStreamBuilder.ask<String>()
          .map((hello) => '$hello World')
          .build();

  readerStream('Hello').listen(print);
}

Functional:

import 'package:functionally/reader_stream.dart' as RS;
import 'package:functionally/common.dart';

void main() {
  final RS.ReaderStream<String, String> readerStream = pipe2(
    RS.ask<String>(),
    RS.map((hello) => '$hello World'),
  );

  readerStream('Hello').listen(print);
}

Examples #

You may also find more examples in Fridgy, an app written with this library.

Anyway, these samples will probably not help you much if you don't have experience with pure functional paradigms. If you have experience with typescript and want to learn more, i suggest searching online guides about fp-ts. Otherwise consider learning Haskell or Scala :P.

0
likes
0
pub points
0%
popularity

Publisher

verified publishergaudo.net

A library designed to help develop code in a more FP oriented way.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

rxdart

More

Packages that depend on functionally