GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mode89/sodium-python: Python implementation of Sodium - Functional Reactive Programming (FRP) Library

BranchesTags
Open more actions menu

Latest commit

 

History

91 Commits
91 Commits

Folders and files

NameName
Last commit message
Last commit date
docs
docs
 
 
examples
examples
 
 
sodiumfrp
sodiumfrp
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
setup.py
setup.py
 
 

Repository files navigation

Sodium

Port of Sodium - Functional Reactive Programming (FRP) library - to Python.

Installation

Just pip install sodiumfrp.

Main Concepts

Streams and Cells

This library is based on two types: Stream and Cell. Stream represents a stream of events, while Cell represents a value that changes over time.

Operators

There is also a bunch of primitives that you can use to build streams/cells and to compose them together. They provide means for doing common operations like mapping, filtering, reduction, flat-mapping and more. All of them are implemented as members of Stream and Cell classes.

Forward references

In situations, where a stream or cell needs to be referenced before it is assigned, use StreamLoop or CellLoop.

Interfacing with imperative world

Stream and Cell lets you model your business logic in a purely functional way. In order to provide your model with input data, use StreamSink and CellSink. And, whenever you need to get data out of the model, use Stream.listen() and Cell.listen().

When an input value is pushed into a stream or cell, Sodium automatically starts a transaction. Any state changes, that occur as a result of that input, are performed within the same transaction. Most of the time you don't need to do anything, but it is possible to start a transaction explicitly via Transaction.run(). For example:

  • It often makes sense for all the program initialization to be wrapped in a single, big transaction.
  • StreamLoop and CellLoop require an explicit transaction.

The Book

The most comprehensive guide on FRP and this library would be the book Functional Reactive Programming by Stephen Blackheath. Even though, the book aims Java, it is pretty straightforward to map it into Python.

Examples

See examples directory.

Development

To run the tests, execute pytest from the package directory.

To build API reference, go to docs directory and run make html. It requires sphinx and sphinx-rtd-theme packages to be installed.

License

Distributed under BSD 3-Clause.

About

Python implementation of Sodium - Functional Reactive Programming (FRP) Library

sodium-python.readthedocs.io

Topics

frpfunctional-programmingfunctional-reactive-programmingpython

Resources

Readme
Activity

Stars

6 stars

Watchers

2 watching

Forks

2 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.