Comments (2)
Attempt 1
The first strategy in dealing with the above-mentioned design issue is to split the outputs and feed them back to the inputs separately. A drawback is that multiple function outputs need to be expressed as tuples, but I have no choice... This means that I need to define some new tuple utility operators (code in private fork):
(<>) :: f -> (a1, a2, ...) -> f -> a1 -> a2 -> ... -- a currying operator
($$) :: (f1, f2, ...) -> (a1, a2, ...) -> (f1 a1, f2 a2, ...) -- a function application operator
(-&>>-) = ($$) (delay, delay) -- a tupled delay
scanld12
becomes:
scanld12 :: (b1 -> b2 -> a1 -> (b1, b2)) -> (e (t, b1), e (t, b2))
-> S (e (t, a1)) -> (S (e (t, b1)), S (e (t, b1)))
scanld12 ns i s1 = st
where st = i -&>>- (comb32 ns <> st) s1
Great, I have well-formed signals between atoms, everything compiles and it's just dandy! Let's run the tests... wait! This particular process deadlocks! But why?
Digging a bit into how the evaluation is done, it is easy to notice that the self-referential function expects an fully-evaluated kernel to build a recursive structure from. A recursive structure meaning a signal... but we generate a tuple of signals which we then feed to generate the next element... do you see what's wrong here? A tuple of signals needs all its elements fully evaluated to be useful, so it waits for the signals to be evaluated... but the signals wait for the tuple to be evaluated... and so on and so forth.
It first seems that we cannot use tuples of signals to feed back into generators.
from forsyde-atom.
Attempt 2
It seems that it is not the tupled outputs that are blocking the feedback loop. The simulation seems to stop when evaluating the newly defined tuple operators themselves, more precisely the ($$)
operator, for the reason described in Attempt 1. Thus the tupled delay (-&>>-)
is malign in this case. By expanding these operators and describing the connections explicitly, the simulation follows its normal course. The following attempt was successful:
gen ns i = (st1, st2)
where st1 = delay (fst i) (fst $ comb22 ns st1 st2)
st2 = delay (snd i) (snd $ comb22 ns st1 st2)
and testing it grants the expected results:
λ> let f a b = (a + b, a - b)
λ> let x = gen f (1,2)
λ> takeS 5 $ snd x
{2,-1,4,-2,8}
λ> takeS 5 $ fst x
{1,3,2,6,4}
Not it is a matter of prettyfying the code in order to be readable and to reflect pattern formation.
Update: this looks better:
gen ns (i1, i2) = let (ns1, ns2) = comb22 ns st1 st2
(st1, st2) = (i1 -&>- ns1, i2 -&>- ns2)
in (st1, st2)
from forsyde-atom.
Related Issues (20)
- Complete documentation of the Synchronization Layer
- Skeleton layer atoms as polymorphic type class
- At least one "structured type" for the skeleton layer
- Test cases and CI for implemented skeletons
- cabal haddock does not find figures HOT 1
- ! LaTeX Error: File `forsyde-math.sty' not found. HOT 1
- Make won't compile the documents. HOT 2
- Split MoC class into Timed and Untimed HOT 1
- Force separation between MoC and Behavior layer
- Document new features HOT 1
- A more efficient way to describe explicit tags HOT 1
- Add classes of behaviors for each layer
- Describing statistics HOT 1
- Add plotting and dumping features HOT 1
- Time type class HOT 2
- ExB extend and Applicative pure redundant
- `<>` utility wrong infix
- `CT.sampDE` generates two initial events
- Small issue fixes for next release
- Typo on `ForSyDe.Atom.MoC.SDF`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forsyde-atom.