Is there a way to have a Behavior t [a]
where the values of [a] at time t are the values contained in a Behavior t [Behavior t a]
at time t? I.e, a function with the type of:
Behavior t [Behavior t a] -> Behavior t [a]
If this is not possible, is that because of a logical impossibility or a limitation in reactive-banana?
The type is trivially inhabited for any
Applicative
:which is clearly not what you intended. So let's ask for inhabitation of
or more generally for which applicatives we can construct
This is inhabited for any
f
that is also a monad:An obvious question arises: If an applicative has such an
f
, does it have to be a monad? The answer is yes. We just applyf
to theIdentity
traversable (one-element collection - theTraversable
instance ofIdentity
) and constructjoin
asSo our function is inhabited precisely for those applicatives that are also monads.
To conclude: The function you're seeking would exist if and only if
Behavior
were aMonad
. And because it is not, most likely there is no such function. (I believe that if there were a way how to make it a monad, it'd be included in the library.)