>>> import Control.Arrow (runKleisli) >>> import Control.Monad.Logger (runStdoutLoggingT) >>> import InfBackprop (call)
>>> runStdoutLoggingT $ runKleisli (call (+)) (2, 2) [Info] Calculating sum of 2 and 2 => 4 4
>>> import Prelude (Float) >>> import InfBackprop (call, derivative)
>>> call (+) (2, 3) :: Float 5.0
>>> import Debug.SimpleExpr.Expr (variable) >>> x = variable "x" >>> y = variable "y" >>> derivative (+) (x, y) (1,1)
fresh :: MonadState Int m => m Int fresh = do id += 1 use id
>>> execState (do _1 += c; _2 += d) (a,b) (a + c,b + d)
>>> execState (do _1.at 1.non 0 += 10) (Map.fromList [(2,100)],"hello") (fromList [(1,10),(2,100)],"hello")
(+=) :: (MonadState s m, Num a) => Setter' s a -> a -> m () (+=) :: (MonadState s m, Num a) => Iso' s a -> a -> m () (+=) :: (MonadState s m, Num a) => Lens' s a -> a -> m () (+=) :: (MonadState s m, Num a) => Traversal' s a -> a -> m ()
>>> (a,b) & _1 +~ c (a + c,b)
>>> (a,b) & both +~ c (a + c,b + c)
>>> (1,2) & _2 +~ 1 (1,3)
>>> [(a,b),(c,d)] & traverse.both +~ e [(a + e,b + e),(c + e,d + e)]
(+~) :: Num a => Setter' s a -> a -> s -> s (+~) :: Num a => Iso' s a -> a -> s -> s (+~) :: Num a => Lens' s a -> a -> s -> s (+~) :: Num a => Traversal' s a -> a -> s -> s
[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]If the first list is not finite, the result is the first list. WARNING: This function takes linear time in the number of elements of the first list.