Popularity
8.0
Stable
Activity
0.0
Stable
36
6
4
Monthly Downloads: 72
Programming language: Haskell
License: MIT License
varying alternatives and similar packages
Based on the "Control" category.
Alternatively, view varying alternatives based on common mentions on social networks and blogs.
-
transient
A full stack, reactive architecture for general purpose programming. Algebraic and monadically composable primitives for concurrency, parallelism, event handling, transactions, multithreading, Web, and distributed computing with complete de-inversion of control (No callbacks, no blocking, pure state) -
distributed-closure
Serializable closures for distributed programming. -
selective
Selective Applicative Functors: Declare Your Effects Statically, Select Which to Execute Dynamically -
classy-prelude-yesod
Type classes for mapping, folding, and traversing monomorphic containers -
auto
Haskell DSL and platform providing denotational, compositional api for discrete-step, locally stateful, interactive programs, games & automations. http://hackage.haskell.org/package/auto -
hask
Category theory for Haskell with a lens flavor (you need GHC 7.8.3, not 7.8.2 to build this!) -
extensible-effects
Extensible Effects: An Alternative to Monad Transformers -
classy-prelude
Type classes for mapping, folding, and traversing monomorphic containers -
ComonadSheet
A library for expressing "spreadsheet-like" computations with absolute and relative references, using fixed-points of n-dimensional comonads. -
transient-universe
A Cloud monad based on transient for the creation of Web and reactive distributed applications that are fully composable, where Web browsers are first class nodes in the cloud -
abstract-par
Type classes generalizing the functionality of the 'monad-par' library. -
these
An either-or-both data type, with corresponding hybrid error/writer monad transformer. -
distributed-fork
A distributed data processing framework in Haskell. -
cloud-haskell
This is an umbrella development repository for Cloud Haskell -
distributed-process-platform
DEPRECATED (Cloud Haskell Platform) in favor of distributed-process-extras, distributed-process-async, distributed-process-client-server, distributed-process-registry, distributed-process-supervisor, distributed-process-task and distributed-process-execution -
monad-validate
A Haskell monad transformer library for data validation -
monad-control
Lift control operations, like exception catching, through monad transformers -
monad-time
Type class for monads which carry the notion of the current time. -
operational
Implement monads by specifying instructions and their desired operational semantics. -
ixmonad
Provides 'graded monads' and 'parameterised monads' to Haskell, enabling fine-grained reasoning about effects. -
effect-monad
Provides 'graded monads' and 'parameterised monads' to Haskell, enabling fine-grained reasoning about effects. -
freer-effects
An implementation of "Freer Monads, More Extensible Effects".
Less time debugging, more time building
Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development.
Promo
scoutapm.com
Do you think we are missing an alternative of varying or a related project?
README
varying
This library provides automaton based value streams and sequencing useful for functional reactive programming (FRP) and locally stateful programming (LSP).
Getting started
module Main where
import Control.Varying
import Control.Applicative
import Control.Concurrent (forkIO, killThread)
import Data.Functor.Identity
import Data.Time.Clock
-- | A simple 2d point type.
data Point = Point { px :: Float
, py :: Float
} deriving (Show, Eq)
newtype Delta = Delta { unDelta :: Float }
-- An exponential tween back and forth from 0 to 50 over 1 seconds that
-- loops forever. This spline takes float values of delta time as input,
-- outputs the current x value at every step.
tweenx :: Monad m => TweenT Float Float m Float
tweenx = do
-- Tween from 0 to 50 over 1 second
tween_ easeOutExpo 0 50 1
-- Chain another tween back to the starting position
tween_ easeOutExpo 50 0 1
-- Loop forever
tweenx
-- An exponential tween back and forth from 0 to 50 over 1 seconds that never
-- ends.
tweeny :: Monad m => TweenT Float Float m Float
tweeny = do
tween_ easeOutExpo 50 0 1
tween_ easeOutExpo 0 50 1
tweeny
-- Our time signal counts input delta time samples.
time :: Monad m => VarT m Delta Float
time = var unDelta
-- | Our Point value that varies over time continuously in x and y.
backAndForth :: Monad m => VarT m Delta Point
backAndForth =
-- Turn our splines into continuous output streams. We must provide
-- a starting value since splines are not guaranteed to be defined at
-- their edges.
let x = tweenStream tweenx 0
y = tweenStream tweeny 0
in
-- Construct a varying Point that takes time as an input.
(Point <$> x <*> y)
-- Stream in a time signal using the 'plug left' combinator.
-- We could similarly use the 'plug right' (~>) function
-- and put the time signal before the construction above. This is needed
-- because the tween streams take time as an input.
<~ time
main :: IO ()
main = do
putStrLn "An example of value streams using the varying library."
putStrLn "Enter a newline to continue, and then a newline to quit"
_ <- getLine
t <- getCurrentTime
tId <- forkIO $ loop backAndForth t
_ <- getLine
killThread tId
loop :: Var Delta Point -> UTCTime -> IO ()
loop v t = do
t1 <- getCurrentTime
-- Here we'll run in the Identity monad using a time delta provided by
-- getCurrentTime and diffUTCTime.
let dt = realToFrac $ diffUTCTime t1 t
Identity (Point x y, vNext) = runVarT v $ Delta dt
xStr = replicate (round x) ' ' ++ "x" ++ replicate (50 - round x) ' '
yStr = replicate (round y) ' ' ++ "y" ++ replicate (50 - round y) ' '
str = zipWith f xStr yStr
f 'x' 'y' = '|'
f 'y' 'x' = '|'
f a ' ' = a
f ' ' b = b
f _ _ = ' '
putStrLn str
loop vNext t1
Publications
The concept of VarT
that this library is built on is isomorphic to Monadic Stream Functions as defined in "Functional Reactive Programming, Refactored" (mirror).
The isomorphism is
toMSF :: Functor m => VarT m a b -> MSF m a b
toMSF = MSF . (fmap . fmap . fmap $ toMSF) . runVarT
toVarT :: Functor m => MSF m a b -> VarT m a b
toVarT = VarT . (fmap . fmap . fmap $ toVarT) . unMSF