dunai

Generalised reactive framework supporting classic, arrowized and monadic FRP.

https://github.com/ivanperez-keera/dunai

Version on this page:0.4.0.0
LTS Haskell 21.25:0.11.2
Stackage Nightly 2023-06-21:0.11.0
Latest on Hackage:0.12.2

See all snapshots dunai appears in

BSD-3-Clause licensed by Ivan Perez, Manuel Bärenz
Maintained by [email protected]
This version can be pinned in stack with:dunai-0.4.0.0@sha256:c505bb8823e979a6e337fc23a5601bfaa8d70c07c7485a06db10013048a30b15,4551

Module documentation for 0.4.0.0

  • Control
    • Control.Monad
      • Control.Monad.Trans
        • Control.Monad.Trans.MSF
          • Control.Monad.Trans.MSF.Except
          • Control.Monad.Trans.MSF.GenLift
          • Control.Monad.Trans.MSF.Maybe
          • Control.Monad.Trans.MSF.Random
          • Control.Monad.Trans.MSF.Reader
          • Control.Monad.Trans.MSF.State
          • Control.Monad.Trans.MSF.Writer
  • Data
    • Data.MonadicStreamFunction
      • Data.MonadicStreamFunction.Async
      • Data.MonadicStreamFunction.Core
      • Data.MonadicStreamFunction.Instances
        • Data.MonadicStreamFunction.Instances.ArrowChoice
        • Data.MonadicStreamFunction.Instances.ArrowLoop
        • Data.MonadicStreamFunction.Instances.ArrowPlus
        • Data.MonadicStreamFunction.Instances.Num
        • Data.MonadicStreamFunction.Instances.VectorSpace
      • Data.MonadicStreamFunction.Parallel
      • Data.MonadicStreamFunction.ReactHandle
      • Data.MonadicStreamFunction.Util
    • Data.VectorSpace
      • Data.VectorSpace.Fractional
      • Data.VectorSpace.Specific
      • Data.VectorSpace.Tuples

Dunai is a DSL for strongly-typed CPS-based composable transformations.

Dunai is based on a concept of Monadic Stream Functions (MSFs). MSFs are transformations defined by a function unMSF :: MSF m a b -> a -> m (b, MSF m a b) that executes one step of a simulation, and produces an output in a monadic context, and a continuation to be used for future steps.

MSFs are a generalisation of the implementation mechanism used by Yampa, Wormholes and other FRP and reactive implementations.

When combined with different monads, they produce interesting effects. For example, when combined with the Maybe monad, they become transformations that may stop producing outputs (and continuations). The Either monad gives rise to MSFs that end with a result (akin to Tasks in Yampa, and Monadic FRP).

Flattening, that is, going from some structure MSF (t m) a b to MSF m a b for a specific transformer t often gives rise to known FRP constructs. For instance, flattening with EitherT gives rise to switching, and flattening with ListT gives rise to parallelism with broadcasting.

MSFs can be used to implement many FRP variants, including Arrowized FRP, Classic FRP, and plain reactive programming. Arrowized and applicative syntax are both supported.

For a very detailed introduction to MSFs, see: http://dl.acm.org/citation.cfm?id=2976010 (mirror: http://www.cs.nott.ac.uk/~psxip1/#FRPRefactored).