Copyright | (c) Hanzhong Xu, Meng Meng 2016, |
---|---|
License | MIT License |
Maintainer | hanzh.xu@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
- buildSrc :: SM s a a -> [a]
- simpleSrc :: SM s () a -> [a]
- idSM :: SM () a a
- constSM :: b -> SM () a b
- delaySM :: a -> SM a a a
- arrSM :: (a -> b) -> SM () a b
- foldlSM :: (s -> a -> s) -> s -> SM s a s
- foldlDelaySM :: (s -> a -> s) -> s -> SM s a s
- absorbR :: SM s a b -> (b -> c) -> SM s a c
- absorbL :: (a -> b) -> SM s b c -> SM s a c
- (^>>>) :: (a -> b) -> SM s b c -> SM s a c
- (>>>^) :: SM s a b -> (b -> c) -> SM s a c
- (<<<^) :: SM s b c -> (a -> b) -> SM s a c
- (^<<<) :: (b -> c) -> SM s a b -> SM s a c
- composeSM :: SM s1 b c -> SM s0 a b -> SM (s0, s1) a c
- (<<<<) :: SM s1 b c -> SM s0 a b -> SM (s0, s1) a c
- (>>>>) :: SM s0 a b -> SM s1 b c -> SM (s0, s1) a c
- firstSM :: SM s a b -> SM s (a, c) (b, c)
- secondSM :: SM s a b -> SM s (c, a) (c, b)
- productSM :: SM s0 a b -> SM s1 c d -> SM (s0, s1) (a, c) (b, d)
- fanoutSM :: SM s0 a b -> SM s1 a c -> SM (s0, s1) a (b, c)
- (****) :: SM s0 a b -> SM s1 c d -> SM (s0, s1) (a, c) (b, d)
- (&&&&) :: SM s0 a b -> SM s1 a c -> SM (s0, s1) a (b, c)
- leftSM :: SM s a b -> SM s (Either a c) (Either b c)
- rightSM :: SM s a b -> SM s (Either c a) (Either c b)
- sumSM :: SM s0 a b -> SM s1 c d -> SM (s0, s1) (Either a c) (Either b d)
- faninSM :: SM s0 a c -> SM s1 b c -> SM (s0, s1) (Either a b) c
- (++++) :: SM s0 a b -> SM s1 c d -> SM (s0, s1) (Either a c) (Either b d)
- (||||) :: SM s0 a c -> SM s1 b c -> SM (s0, s1) (Either a b) c
- loopSM :: SM s (a, c) (b, c) -> SM s a b
- execSM :: SM s a b -> SM s [a] [b]
- joinSM :: Monad m => SM s a (m (m b)) -> SM s a (m b)
- concatSM :: SM s a [[b]] -> SM s a [b]
- step :: SM s a b -> a -> (SM s a b, b)
- exec :: SM s a b -> [a] -> (SM s a b, [b])
- fmapSM :: (b -> c) -> SM s a b -> SM s a c
Documentation
buildSrc :: SM s a a -> [a] Source #
Source There are two kinds of source. First one is using the output of `SM s a a` as its input, then it becomes a perpetual motion, :) Second one is a SM which ignore its input, and output something based on its storage. The second one is easier to understand and use.
build a source, for example: buildSrc $ foldlDelaySM (const (+1)) 0 [0..] buildSrc $ foldlDelaySM (+) 1 [1, 2, 4, 8, ...]
simpleSrc :: SM s () a -> [a] Source #
build a simple source, which ignore the inputs fibsSM :: SM (Int, Int) () Int fibsSM = simpleSM ((a, b) () -> ((b, a+b), a)) (0, 1) take 10 $ simpleSrc fibsSM [0,1,1,2,3, ...]simpleSrc :: SM s () a -> [a]
delaySM :: a -> SM a a a Source #
delay the input with given value. delaySM = foldlDelaySM (const id)
foldlDelaySM :: (s -> a -> s) -> s -> SM s a s Source #
the difference from foldlSM is it output the storage first.
absorbR :: SM s a b -> (b -> c) -> SM s a c Source #
absorb a function. absorbR sm f = absorbRSM sm (arrSM f) absorbL f sm = absorbLSM (arrSM f) sm
composeSM :: SM s1 b c -> SM s0 a b -> SM (s0, s1) a c Source #
compose two SM and merge their storage.
execSM :: SM s a b -> SM s [a] [b] Source #
converts SM a b -> SM [a] [b], it is very useful to compose SM a [b] and SM b c to SM a [c].
exec :: SM s a b -> [a] -> (SM s a b, [b]) Source #
execute SM a b with input [a]. Also, it is the map function for SM, perhaps, We should define our own Functor class, the SMFunctor!