FPLib

Functional Programming library for SuperCollider

FPLib

Functional Programming library for SuperCollider

Requirements

Instalation

Move this folder to the SuperCollider 'Extensions' folder.

Overview

Making full use of this library requires knowledge of modern Functional Programming concepts as implemented for instance in Haskell, specially familiarity with functors, applicative functors, monoids and monads.

I recommend reading a book such as "Learn you a Haskell for greater good".

The Library implements an experimental type class system, where the functions of the type classes are defined in Object and to "implement" a type class a SuperCollider class has to overload the corresponding functions (i.e. >>= or collect). This doesn't allow for more advanced uses of type classes but allows defining functions that are available to a specific type class, by defining a corresponding method in Object (i.e. sequence depends on traverse, >>=| depends on >>=). If one calls >>=| on a class that is not a monad (doesn't implement >>= ) an error is thrown. Some methods such as sequence cannot be used like in Haskell because SuperCollider doesn't have the sophisticated type system to infere the right class to use in some circunstances. In those cases o type hint must be given:

[].sequence(Option)

Without this type hint, there would be no way to know in what class to wrap the empty array.

Type Classes:

Functor

  • needs: collect

Applicative Functor (AF):

  • needs: <*>, *makePure
  • makes available: <*, *>, <%>, sequence, pure

Monad

  • needs: >>=, *makePure (we don't distinguish between AF's pure and Monad's return)
  • makes available: >>=|, sequenceM, pure

Monoid

  • needs: |+|, *zero

Traverse

  • needs: traverse
  • makes available: collectTraverse, disperse

Instances of Type Classes:

  • IO
  • Option
  • Validation
  • Promise
  • Reader
  • ST
  • WriterReader
  • RWST

New collections:

  • LazyList
  • Tuple(n)

Functional Reactive Programming

Classes: FPSignal, EventStream and their children.

These classes are based on scala and haskell implementations of FRP.

A monad for constructing the event processors graph is available which is compiled into a EventNetwork which can be started and stopped at will. The network description itself has this pseudo type:

//networkDescription : Writer( Unit, Tuple3([IO(IO())], [EventStream[IO[Unit]]], [IO] ) ) // eventHandlers reactimates IOLater

More info

See the help files, including the reference page, the examples directory and also there are some blog posts relating to FP Lib at http://www.friendlyvirus.org/miguelnegrao/category/code/.

AbstractFunction
Extension
Superclass:
ApplyFPSignal
Project
Source file
Extension
Superclass:
FPSignal
Array
Extension
Superclass:
ArrayedCollection
Extension
Superclass:
Boolean
Extension
Superclass:
Buffer
Project
Source file
Extension
Superclass:
ChildEventSource
Extension
Superclass:
EventSource
ChildFPSignal
Project
Source file
Extension
Superclass:
FPSignal
CollectedES
Extension
Superclass:
ChildEventSource
CollectedFPSignal
Project
Source file
Extension
Superclass:
ChildFPSignal
Collection
Extension
Superclass:
Dictionary
Extension
Superclass:
DoNotation
Project
Source file
Extension
Superclass:
ENImperEval
Extension
Superclass:
ENTimer
Extension
Superclass:
ENdef
Project
Source file
Extension
Superclass:
EventNetwork
Extension
Superclass:
EventPlayerES
Extension
Superclass:
EventSource
EventSource
Project
Source file
Extension
Superclass:
EventStream
Extension
Superclass:
FPSignal
Project
Source file
Extension
Superclass:
FRP
Project
Source file
Extension
Superclass:
Namespace
FRPDef
Project
Source file
Extension
Superclass:
FRPPlayControl
Project
Source file
Extension
Superclass:
AbstractPlayControl
Failure
Project
Source file
Extension
Superclass:
Validation
False
Project
Source file
Extension
Superclass:
FlatCollectedES
Extension
Superclass:
ChildEventSource
FlatCollectedFPSignal
Project
Source file
Extension
Superclass:
ChildFPSignal
FlatCollectedFPSignalHybrid
Project
Source file
Extension
Superclass:
ChildFPSignal
FoldedES
Extension
Superclass:
ChildEventSource
FoldedFES
Extension
Superclass:
ChildEventSource
FoldedFPSignal
Project
Source file
Extension
Superclass:
ChildFPSignal
Function
Project
Source file
Extension
Superclass:
HideVar
Extension
Superclass:
Var
HoldFPSignal
Extension
Superclass:
FPSignal
I
Project
Source file
Extension
Superclass:
IO
Project
Source file
Extension
Superclass:
LL
Extension
Superclass:
LazyList
Extension
Superclass:
LazyListCons
Extension
Superclass:
LazyList
LazyListEmpty
Extension
Superclass:
LazyList
LiftedFunc
Project
Source file
Extension
Superclass:
M
Project
Source file
Extension
Superclass:
Namespace
Extension
Superclass:
MergedES
Extension
Superclass:
EventSource
MonoidAll
Project
Source file
Extension
Superclass:
MonoidAny
Project
Source file
Extension
Superclass:
MonoidProduct
Project
Source file
Extension
Superclass:
MonoidSum
Project
Source file
Extension
Superclass:
NNdef
Project
Source file
Extension
Superclass:
Ndef
Namespace
Project
Source file
Extension
Superclass:
Environment
Ndef
Project
Source file
Extension
Superclass:
NetAddr
Project
Source file
Extension
Superclass:
NetworkDesc
Project
Source file
Extension
Superclass:
RWS
Nil
Project
Source file
Extension
Superclass:
Node
Project
Source file
Extension
Superclass:
None
Project
Source file
Extension
Superclass:
Option
NothingES
Extension
Superclass:
EventSource
OSCFunc
Extension
Superclass:
Object
Extension
Superclass:
Option
Project
Source file
Extension
Superclass:
PApplicativeFunctor
Extension
Superclass:
Pattern
Pattern
Extension
Superclass:
PenAnnularWedge
Project
Source file
Extension
Superclass:
PenShape
PenArcTo
Project
Source file
Extension
Superclass:
PenShapeStep
PenCurveTo
Project
Source file
Extension
Superclass:
PenShapeStep
PenDrawedShapes
Project
Source file
Extension
Superclass:
PenDrawing
Project
Source file
Extension
Superclass:
PenLineTo
Project
Source file
Extension
Superclass:
PenShapeStep
PenOval
Project
Source file
Extension
Superclass:
PenShape
PenQuadCurveTo
Project
Source file
Extension
Superclass:
PenShapeStep
PenRect
Project
Source file
Extension
Superclass:
PenShape
PenShape
Project
Source file
Extension
Superclass:
PenShapeStep
Project
Source file
Extension
Superclass:
PenStepShape
Project
Source file
Extension
Superclass:
PenShape
PenWedge
Project
Source file
Extension
Superclass:
PenShape
Promise
Project
Source file
Extension
Superclass:
RWS
Project
Source file
Extension
Superclass:
RWSArr
Project
Source file
Extension
Superclass:
RWS
RWST
Project
Source file
Extension
Superclass:
RWSTArr
Project
Source file
Extension
Superclass:
RWST
RWSTArrE
Project
Source file
Extension
Superclass:
RWSTArr
RWSTArrO
Project
Source file
Extension
Superclass:
RWSTArr
Reader
Project
Source file
Extension
Superclass:
ST
Project
Source file
Extension
Superclass:
SelectedES
Extension
Superclass:
ChildEventSource
SelfSwitchFPSignal
Project
Source file
Extension
Superclass:
ChildFPSignal
SignalChangeES
Project
Source file
Extension
Superclass:
EventSource
SimpleNumber
Extension
Superclass:
Some
Project
Source file
Extension
Superclass:
Option
Stream
Extension
Superclass:
String
Extension
Superclass:
Success
Project
Source file
Extension
Superclass:
Validation
SynthDef
Project
Source file
Extension
Superclass:
T
Project
Source file
Extension
Superclass:
TakeWhileES
Extension
Superclass:
ChildEventSource
TakeWhileFPSignal
Project
Source file
Extension
Superclass:
ChildFPSignal
TestFP
Project
Source file
Extension
Superclass:
UnitTest
TestFRP
Project
Source file
Extension
Superclass:
UnitTest
Extension
Superclass:
EventSource
True
Project
Source file
Extension
Superclass:
Unit
Project
Source file
Extension
Superclass:
UserView
Project
Source file
Extension
Superclass:
Val
Project
Source file
Extension
Superclass:
FPSignal
Validation
Project
Source file
Extension
Superclass:
Var
Project
Source file
Extension
Superclass:
Val
View
Project
Source file
Extension
Superclass:
Extension
Superclass:
EventSource
Window
Project
Source file
Extension
Superclass:
Writer
Project
Source file
Extension
Superclass:
WriterReader
Extension
Superclass:
v0.2.1
Date
2015-09-23
Git hash
ace76753f39389697b9c02c838fe004a02cad433
v0.2.0
Date
2015-03-28
Git hash
1b0f74ec9bc51deec1e7290a5bbb63c3c3930d9d
v0.1.0
Date
2013-01-19
Git hash
d5563fd110930cf5686510e54016639d2eba643b

Installation

Repository

URL

https://github.com/miguel-negrao/FPLib

Since

2012-03-12

Last update

2021-01-18

Current version

v0.2.1

Quark info

name

FPLib

schelp

FP Lib

license

GPL3

summary

Functional Programming library for SuperCollider

version

0.3.1

copyright

Miguel Negrão 2012-2018

dependencies

['JITLibExtensions', 'Modality-toolkit']

Possible dependcies

JITLibExtensions

Modality-toolkit

Possible dependants