Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class RandomAccessList e where
- type Element e ∷ Type
- empty ∷ e
- cons ∷ Element e → e → e
- uncons ∷ e → Maybe (Element e, e)
- length ∷ e → Word64
- consSlab ∷ NonEmptyVector (Element e) → e → e
- indexZero ∷ e → Word64 → Maybe (Element e)
- indexOne ∷ e → Word64 → Maybe (Element e)
- unsafeIndexZero ∷ e → Word64 → Element e
- unsafeIndexOne ∷ e → Word64 → Element e
- head ∷ (RandomAccessList e, a ~ Element e) ⇒ e → a
- tail ∷ RandomAccessList e ⇒ e → e
- newtype AsRAL a = AsRAL a
Documentation
class RandomAccessList e where Source #
Typeclass for various types implementing the "signature" of a random-access list.
A true random-access list should have good asymptotic behaviour for these methods also, but for convenience we also provide implementations for e.g. '[a]', which has bad lookup performance.
The empty list.
cons ∷ Element e → e → e Source #
Prepend an element to the list.
uncons ∷ e → Maybe (Element e, e) Source #
Un-prepend an element to the list.
Get the length of the list. May have linear complexity, but useful.
consSlab ∷ NonEmptyVector (Element e) → e → e Source #
Prepend many elements to the list. Has a default implementation, but implementations can provide more efficient ones.
indexZero ∷ e → Word64 → Maybe (Element e) Source #
Lookup an element in the list. 0-based index.
indexOne ∷ e → Word64 → Maybe (Element e) Source #
Lookup an element in the list. 1-based index.
unsafeIndexZero ∷ e → Word64 → Element e Source #
Lookup an element in the list, partially.
unsafeIndexOne ∷ e → Word64 → Element e Source #
Lookup an element in the list, partially.
Instances
tail ∷ RandomAccessList e ⇒ e → e Source #