turion / rhine

Haskell Functional Reactive Programming framework with type-level clocks
http://hackage.haskell.org/package/rhine
124 stars 21 forks source link

Signal networks, clocked signal functions and resampling buffers are profunctors #138

Open turion opened 4 years ago

turion commented 4 years ago

I think that for any functor m and clocks cl, cl', all ClSF m cl, SN m cl and Resbuf m cl cl' are instances of Profunctor. This means that we can pre- and postcompose them with pure functions, and that precomposition is contravariant. In arrows, precomposition is known as the (^>>) operator.

To do

Sometimes, operators like http://hackage.haskell.org/package/rhine-0.6.0/docs/FRP-Rhine-SN-Combinators.html#v:-62--62--62--94- can be reused.

freckletonj commented 3 years ago

I'm still wrapping my head around dunai/rhine, but if ClSF and SN are profunctors, shouldn't we more simply just make MSF a profunctor?

turion commented 3 years ago

That's absolutely right. If MSF were a profunctor, ClSF would automatically become one. SN would require a separate instance, but it's not hard.

See also:

https://github.com/ivanperez-keera/dunai/issues/224

turion commented 3 years ago

Similarly, I believe that at least ClSFs are Traversing. See https://github.com/ivanperez-keera/dunai/issues/224#issuecomment-825053518.