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 aData.Stream.Future.Skewprovides a non-empty skew-binary random-access-list with the semantics ofData.Stream.Future. As withData.Stream.Futurethis stream is not aMonad, since theApplicativeinstance zips streams of potentially differing lengths. The random-access-list structure provides a number of operations logarithmic access time, but makesData.Stream.Future.Skew.consless productive. Where applicableData.Stream.Infinite.Skewmay be more efficient, due to a lazier and more efficientApplicativeinstance.
Data.Stream.Infiniteprovides a coinductive infinite anti-causal stream. TheComonadprovides access to the tail of the stream and theApplicativezips streams together. UnlikeFuture, infinite stream form aMonad. The monad diagonalizes theStream, which is consistent with the behavior of theApplicative, and the view of aStreamas a isomorphic to the reader monad from the natural numbers. Being infinite in length, there is noAlternativeinstance.
data Stream a = a :< Stream aData.Stream.Infinite.Skewprovides an infinite skew-binary random-access-list with the semantics ofData.Stream.InfiniteSince every stream is infinite, theApplicativeinstance can be considerably less strict than the corresponding instance forData.Stream.Future.Skewand performs asymptotically better.
Data.Stream.Infinite.Functional.Zipperprovides 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.Supplyprovides a comonadic supply of unique values, which are generated impurely as the tree is explored.