type-indexed-queues-0.1.0.1: Queues with verified and unverified versions.

Safe HaskellNone
LanguageHaskell2010

Data.Queue.Indexed.List

Description

This module exists to showcase some uses for indexed non-priority queues.

Synopsis

Documentation

data List n a where Source #

A simple length-indexed list.

Constructors

Nil :: List 0 a 
(:-) :: a -> List n a -> List (1 + n) a infixr 5 

Instances

MeldableIndexedQueue List a Source # 

Methods

merge :: List n a -> List m a -> List (n + m) a Source #

IndexedQueue List a Source # 

Methods

empty :: List 0 a Source #

minView :: List (1 + n) a -> (a, List n a) Source #

singleton :: a -> List 1 a Source #

insert :: a -> List n a -> List (1 + n) a Source #

minViewMay :: List n a -> ((Nat ~ n) 0 -> b) -> (forall m. (Nat ~ (1 + m)) n => a -> List m a -> b) -> b Source #

newtype DiffList n a Source #

A list with efficient concatenation.

Constructors

DiffList 

Fields

Instances

MeldableIndexedQueue DiffList a Source #

Performs merging in reverse order.

Methods

merge :: DiffList n a -> DiffList m a -> DiffList (n + m) a Source #

IndexedQueue DiffList a Source # 

Methods

empty :: DiffList 0 a Source #

minView :: DiffList (1 + n) a -> (a, DiffList n a) Source #

singleton :: a -> DiffList 1 a Source #

insert :: a -> DiffList n a -> DiffList (1 + n) a Source #

minViewMay :: DiffList n a -> ((Nat ~ n) 0 -> b) -> (forall m. (Nat ~ (1 + m)) n => a -> DiffList m a -> b) -> b Source #

reverseTraversable :: Traversable t => t a -> t a Source #

Efficiently reverse any traversable, safely and totally.

>>> reverseTraversable [1,2,3]
[3,2,1]
reverseTraversable xs == reverse (xs :: [Int])

reverseTraversal :: ((a -> Parts DiffList List a a a) -> t -> Parts DiffList List a a t) -> t -> t Source #

Efficiently reverse any traversable, safely and totally.

>>> reverseTraversal (traverse.traverse) ('a',[1,2,3])
('a',[3,2,1])