mono-traversable-0.1.0.0: Type classes for mapping, folding, and traversing monomorphic containers

Safe HaskellNone

Data.NonNull

Description

Warning, this is Experimental!

Data.NonNull attempts to extend the concepts from NonEmpty to any IsSequence.

NonNull is for a sequence with 1 or more elements. Stream is for a NonNull that supports efficient modification of the front of the sequence.

This code is experimental and likely to change dramatically and future versions. Please send your feedback.

Synopsis

Documentation

class IsSequence seq => NonNull seq whereSource

a NonNull sequence has 1 or more items

Associated Types

type NonEmpty seq Source

Methods

nsingleton :: Element seq -> NonEmpty seqSource

fromNonEmpty :: NonEmpty (Element seq) -> NonEmpty seqSource

nfilter :: (Element seq -> Bool) -> NonEmpty seq -> seqSource

like filter, but starts with a NonNull

head :: NonEmpty seq -> Element seqSource

like Data.List, but not partial on a NonEmpty

tail :: NonEmpty seq -> seqSource

like Data.List, but not partial on a NonEmpty

last :: NonEmpty seq -> Element seqSource

like Data.List, but not partial on a NonEmpty

init :: NonEmpty seq -> seqSource

like Data.List, but not partial on a NonEmpty

Instances

NonNull [a]

NonNull list reuses NonEmpty

NonNull (Seq a) 
NonNull (Vector a) 

data NotEmpty seq Source

a wrapper indicating there are 1 or more elements unwrap with toSequence

Constructors

NotEmpty 

Fields

toSequence :: seq
 

class NonNull seq => Stream seq whereSource

a stream is a NonNull that supports efficient modification of the front of the sequence

Methods

(.:) :: Element seq -> seq -> NonEmpty seqSource

Prepend an element, creating a NonEmpty Data.List.NonEmpty gets to use the (:|) operator, but this can't because it is not a data constructor

(<|) :: Element seq -> NonEmpty seq -> NonEmpty seqSource

Prepend an element to a NonEmpty

Instances

Stream [a] 
Stream (Seq a)