| Copyright | Copyright (c) 2014 Kenneth Foner |
|---|---|
| Maintainer | kenneth.foner@gmail.com |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.Stream.Tape
Description
This module implements two-way infinite streams with a focused element, akin to a Turing machine's tape. This structure is also known by the name of a list zipper (although in this case it's a list zipper with the additional criterion that the list is infinite in both directions).
Documentation
A Tape is like a Turing-machine tape: infinite in both directions, with a focus in the middle.
Constructors
| Tape | |
Instances
| Functor Tape | |
| Applicative Tape | A tape is |
| Comonad Tape | Tapes form a comonad, where extract gives the focus element and duplicate gives a diagonalized
|
| ComonadApply Tape | Applying one tape to another moves them together. This is like the |
| Distributive Tape | Tapes are |
Arguments
| :: (c -> (a, c)) | leftwards unfolding function |
| -> (c -> a) | function giving the focus value from the seed |
| -> (c -> (a, c)) | rightwards unfolding function |
| -> c | seed value |
| -> Tape a |
Produce a Tape from a seed value, ala unfoldr for lists, or unfold for Streams.
Arguments
| :: (a -> a) | leftwards iteration function |
| -> (a -> a) | rightwards iteration function |
| -> a | focus value |
| -> Tape a |
Produce a Tape consisting of the infinite iteration of two functions to a starting focus value,
ala iterate for lists or Streams.
enumerate :: Enum a => a -> Tape a Source
Given an enumerable type, produce the Tape where the left side is the sequence of predecessors,
and the right side is the sequence of successors.
moveL :: Tape a -> Tape a Source
The functions moveR and moveL move the focus on the tape right and left, respectively.