Safe Haskell | None |
---|---|
Language | Haskell2010 |
- var :: Applicative a => (b -> c) -> Var a b c
- varM :: Monad m => (a -> m b) -> Var m a b
- evalVar :: Functor m => Var m a b -> a -> m b
- execVar :: Functor m => Var m a b -> a -> m (Var m a b)
- loopVar_ :: Monad m => Var m () a -> m ()
- loopVar :: Monad m => a -> Var m a a -> m a
- whileVar_ :: Monad m => (a -> Bool) -> Var m () a -> m a
- whileVar :: Monad m => (a -> Bool) -> a -> Var m a a -> m a
- vtrace :: (Applicative a, Show b) => Var a b b
- vstrace :: (Applicative a, Show b) => String -> Var a b b
- testWhile_ :: Show a => (a -> Bool) -> Var IO () a -> IO ()
- testVar :: (Read a, Show b) => Var IO a b -> IO ()
- testVar_ :: Show b => Var IO () b -> IO ()
- accumulate :: Monad m => (c -> b -> c) -> c -> Var m b c
- delay :: Monad m => b -> Var m a b -> Var m a b
- (<~) :: Monad m => Var m b c -> Var m a b -> Var m a c
- (~>) :: Monad m => Var m a b -> Var m b c -> Var m a c
- data Var m b c = Var {}
Documentation
var :: Applicative a => (b -> c) -> Var a b c Source
Lift a pure computation into a Var
.
loopVar :: Monad m => a -> Var m a a -> m a Source
Loop over a Var
that produces its own next input value.
whileVar_ :: Monad m => (a -> Bool) -> Var m () a -> m a Source
Iterate a Var
that requires no input until the given predicate fails.
:: Monad m | |
=> (a -> Bool) | The predicate to evaluate samples. |
-> a | The initial input/sample value. |
-> Var m a a | The |
-> m a | The last sample |
Iterate a Var
that produces its own next input value until the given
predicate fails.
vtrace :: (Applicative a, Show b) => Var a b b Source
accumulate :: Monad m => (c -> b -> c) -> c -> Var m b c Source
Accumulates input values using a folding function and yields that accumulated value each sample.
(<~) :: Monad m => Var m b c -> Var m a b -> Var m a c infixl 1 Source
Same as ~>
with flipped parameters.
The vessel of a varying value. A Var
is a structure that contains a value
that changes over some input. That input could be time (Float, Double, etc)
or events or a stream of Char
- whatever. Similar to the
State
monad.
A kind of Mealy machine (an automaton) with effects.
Monad m => Category * (Var m) Source | A very simple category instance. id = var id f . g = g ~> f or f . g = f <~ g It is preferable for consistency (and readability) to use 'plug left' ( |
Monad m => Arrow (Var m) Source |
v = proc a -> do ex <- intEventVar -< () ey <- anotherIntEventVar -< () returnA -< (+) <$> ex <*> ey which is equivalent to v = (\ex ey -> (+) <$> ex <*> ey) <$> intEventVar <*> anotherIntEventVar |
Monad m => Functor (Var m b) Source | You can transform the sample value of any fmap (*3) $ accumulate (+) 0 Will sum input values and then multiply the sum by 3. |
Monad m => Applicative (Var m a) Source |
(,) <$> pure True <*> var "Applicative" |
(Monad m, Floating b) => Floating (Var m a b) Source |
let v = pi ~> accumulate (*) 0.0 which will attempt (and succeed) to multiply pi by zero every step. |
(Monad m, Fractional b) => Fractional (Var m a b) Source |
let v = 2.5 ~> accumulate (+) 0 which will add 2.5 each step. |
(Monad m, Num b) => Num (Var m a b) Source |
let v = 1 ~> accumulate (+) 0 which will sum the natural numbers. |