Copyright | (C) 2011-2015 Edward Kmett |
---|---|

License | BSD-style (see the file LICENSE) |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Stability | provisional |

Portability | portable |

Safe Haskell | Safe |

Language | Haskell98 |

This is an infinite bidirectional zipper

- data Zipper a = !Integer :~ !(Integer -> a)
- tail :: Zipper a -> Zipper a
- untail :: Zipper a -> Zipper a
- intersperse :: a -> Zipper a -> Zipper a
- interleave :: Zipper a -> Zipper a -> Zipper a
- transpose :: Zipper (Zipper a) -> Zipper (Zipper a)
- take :: Integer -> Zipper a -> [a]
- drop :: Integer -> Zipper a -> Zipper a
- splitAt :: Integer -> Zipper a -> ([a], Zipper a)
- reverse :: Zipper a -> Zipper a
- (!!) :: Zipper a -> Integer -> a
- unzip :: Zipper (a, b) -> (Zipper a, Zipper b)
- toSequence :: (Integer -> a) -> Zipper a
- head :: Zipper a -> a
- (<|) :: a -> Zipper a -> Zipper a
- uncons :: Zipper a -> (a, Zipper a)
- takeWhile :: (a -> Bool) -> Zipper a -> [a]
- dropWhile :: (a -> Bool) -> Zipper a -> Zipper a
- span :: (a -> Bool) -> Zipper a -> ([a], Zipper a)
- break :: (a -> Bool) -> Zipper a -> ([a], Zipper a)
- isPrefixOf :: Eq a => [a] -> Zipper a -> Bool
- findIndex :: (a -> Bool) -> Zipper a -> Integer
- elemIndex :: Eq a => a -> Zipper a -> Integer
- zip :: Zipper a -> Zipper b -> Zipper (a, b)
- zipWith :: (a -> b -> c) -> Zipper a -> Zipper b -> Zipper c

# The type of streams

intersperse :: a -> Zipper a -> Zipper a Source #

creates an alternating stream of
elements from `intersperse`

y xs`xs`

and `y`

.

interleave :: Zipper a -> Zipper a -> Zipper a Source #

Interleave two Zippers `xs`

and `ys`

, alternating elements
from each list.

[x1,x2,...] `interleave` [y1,y2,...] == [x1,y1,x2,y2,...] interleave = (<>)

transpose :: Zipper (Zipper a) -> Zipper (Zipper a) Source #

`transpose`

computes the transposition of a stream of streams.

drop :: Integer -> Zipper a -> Zipper a Source #

drops the first `drop`

n xs`n`

elements off the front of
the sequence `xs`

.

splitAt :: Integer -> Zipper a -> ([a], Zipper a) Source #

returns a pair consisting of the prefix of
`splitAt`

n xs`xs`

of length `n`

and the remaining stream immediately following
this prefix.

*Beware*: passing a negative integer as the first argument will
cause an error if you access the taken portion

(!!) :: Zipper a -> Integer -> a Source #

`xs !! n`

returns the element of the stream `xs`

at index
`n`

. Note that the head of the stream has index 0.

toSequence :: (Integer -> a) -> Zipper a Source #

(<|) :: a -> Zipper a -> Zipper a Source #

Cons before the head of the zipper. The head now points to the new element

uncons :: Zipper a -> (a, Zipper a) Source #

Move the head of the zipper one step to the right, returning the value we move over.

takeWhile :: (a -> Bool) -> Zipper a -> [a] Source #

returns the longest prefix of the stream
`takeWhile`

p xs`xs`

for which the predicate `p`

holds.

span :: (a -> Bool) -> Zipper a -> ([a], Zipper a) Source #

returns the longest prefix of `span`

p xs`xs`

that satisfies
`p`

, together with the remainder of the stream.

isPrefixOf :: Eq a => [a] -> Zipper a -> Bool Source #

The `isPrefix`

function returns `True`

if the first argument is
a prefix of the second.