Various Haskell 2010 stream comonads.
Various Haskell 2010 stream comonads. * Data.Stream.Future
provides a coinductive anti-causal stream, or non-empty ZipList
. The comonad provides access to only the tail of the stream. Like a conventional ZipList
, this is not a monad.
data Future a = Last a | a :< Future a
Data.Stream.Future.Skew
provides a non-empty skew-binary random-access-list with the semantics ofData.Stream.Future
. As withData.Stream.Future
this stream is not aMonad
, since theApplicative
instance zips streams of potentially differing lengths. The random-access-list structure provides a number of operations logarithmic access time, but makesData.Stream.Future.Skew.cons
less productive. Where applicableData.Stream.Infinite.Skew
may be more efficient, due to a lazier and more efficientApplicative
instance.
Data.Stream.Infinite
provides a coinductive infinite anti-causal stream. TheComonad
provides access to the tail of the stream and theApplicative
zips streams together. UnlikeFuture
, infinite stream form aMonad
. The monad diagonalizes theStream
, which is consistent with the behavior of theApplicative
, and the view of aStream
as a isomorphic to the reader monad from the natural numbers. Being infinite in length, there is noAlternative
instance.
data Stream a = a :< Stream a
Data.Stream.Infinite.Skew
provides an infinite skew-binary random-access-list with the semantics ofData.Stream.Infinite
Since every stream is infinite, theApplicative
instance can be considerably less strict than the corresponding instance forData.Stream.Future.Skew
and performs asymptotically better.
Data.Stream.Infinite.Functional.Zipper
provides a bi-infinite sequence, represented as a pure function with an accumulating parameter added to optimize moving the current focus.
data Zipper a = !Integer :~ (Integer -> a)
Data.Stream.Supply
provides a comonadic supply of unique values, which are generated impurely as the tree is explored.