-
Notifications
You must be signed in to change notification settings - Fork 13
Home
Dif(fuser) lets you declaratively define relationships between immutable data and side effects. It was intended to be used for UI development, but the APIs are general enough to be applied to any domain.
This library contains two main building blocks: Diffuser
and Fuser
.
Diffuser
lets you define how data should be translated into side-effects, and Fuser
lets you define how side-effects should be transformed back into data. By combining these two, you can effectively wrap a side-effecting domain entirely in a pure context.
A key insight to understanding Diffuser
and Fuser
is to understand that they both form a language. A Diffuser
can be built from the primitive into
expression, and Diffuser
s can be combined using the map
and intoAll
combinators. The combination of two Diffuser
s is itself a Diffuser
, so you can reason about the combination in the same way you reason about the individual parts. This language can be extended arbitrarily and freely by writing functions which take and return Diffuser
s. Similarly, a primitive Fuser
is created using from
and can be combined freely with fromAll
and extract
.