Skip to content

fgaudo/functionally

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 way which uses builders to chain methods and build the functional types.
  2. A more functional way 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 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages