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

Safe HaskellNone
LanguageHaskell2010

Data.Queue.Indexed.Leftist

Description

Statically verified, type-indexed, weight-biased leftist heaps.

Synopsis

Documentation

data Leftist n a where Source #

A size-indexed weight-biased leftist heap. Somewhat based on the implementation from here.

Type-level natural numbers are used to maintain the invariants in the size of the structure, but these are backed by Natural at runtime, maintaining some efficiency.

For instance, the <=. function is used, which compares two numbers (runtime integers), but provides a boolean singleton as its result: when matched on, this provides a type-level-proof of the ordering.

Constructors

Leaf :: Leftist 0 a 
Node :: !(The Nat ((n + m) + 1)) -> a -> Leftist n a -> Leftist m a -> !(m <= n) -> Leftist ((n + m) + 1) a 

Instances

Ord a => MeldableIndexedQueue Leftist a Source # 

Methods

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

Ord a => IndexedQueue Leftist a Source # 

Methods

empty :: Leftist 0 a Source #

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

singleton :: a -> Leftist 1 a Source #

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

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

NFData a => NFData (Leftist n a) Source # 

Methods

rnf :: Leftist n a -> () #