sdp-0.2.1.1: Simple Data Processing
Copyright(c) Andrey Mulik 2019-2021
LicenseBSD-style
Maintainerwork.a.mulik@gmail.com
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

SDP.Sort

Description

SDP.Sort provides Sort - class of sortable immutable structures.

Synopsis

Sort

class Sort s e | s -> e where Source #

Sort is class of types that can be sorted.

Methods

sortedBy :: (e -> e -> Bool) -> s -> Bool Source #

Checks if structure is already sorted. Should always return True for structures with less than 2 elements.

sortBy :: Compare e -> s -> s Source #

sortBy function is common sorting algorithm.

Instances

Instances details
Sort [a] a Source # 
Instance details

Defined in SDP.Sort

Methods

sortedBy :: (a -> a -> Bool) -> [a] -> Bool Source #

sortBy :: Compare a -> [a] -> [a] Source #

Unboxed e => Sort (SBytes# e) e Source # 
Instance details

Defined in SDP.Prim.SBytes

Methods

sortedBy :: (e -> e -> Bool) -> SBytes# e -> Bool Source #

sortBy :: Compare e -> SBytes# e -> SBytes# e Source #

Sort (SArray# e) e Source # 
Instance details

Defined in SDP.Prim.SArray

Methods

sortedBy :: (e -> e -> Bool) -> SArray# e -> Bool Source #

sortBy :: Compare e -> SArray# e -> SArray# e Source #

Sort (Unlist e) e Source # 
Instance details

Defined in SDP.Unrolled.Unlist

Methods

sortedBy :: (e -> e -> Bool) -> Unlist e -> Bool Source #

sortBy :: Compare e -> Unlist e -> Unlist e Source #

Unboxed e => Sort (Ublist e) e Source # 
Instance details

Defined in SDP.ByteList.Ublist

Methods

sortedBy :: (e -> e -> Bool) -> Ublist e -> Bool Source #

sortBy :: Compare e -> Ublist e -> Ublist e Source #

(Index i, Sort (rep e) e) => Sort (AnyBorder rep i e) e Source # 
Instance details

Defined in SDP.Templates.AnyBorder

Methods

sortedBy :: (e -> e -> Bool) -> AnyBorder rep i e -> Bool Source #

sortBy :: Compare e -> AnyBorder rep i e -> AnyBorder rep i e Source #

type Sort1 rep e = Sort (rep e) Source #

Sort contraint for (Type -> Type)-kind types.

type Sort2 rep i e = Sort (rep i e) Source #

Sort contraint for (Type -> Type -> Type)-kind types.

Rank 2 quantified constraints

GHC 8.6.1+ only

type Sort' rep = forall e. Sort (rep e) Source #

Sort quantified contraint for (Type -> Type)-kind types.

type Sort'' rep = forall i e. Sort (rep i e) Source #

Sort quantified contraint for (Type -> Type -> Type)-kind types.

Helpers

sort :: (Sort s e, Ord e) => s -> s Source #

sortOn :: (Sort s e, Ord o) => (e -> o) -> s -> s Source #

Sort by comparing the results of a given function applied to each element.

sorted :: (Sort s e, Ord e) => s -> Bool Source #

Checks if the structure is sorted.

sortedOn :: (Sort s e, Ord o) => (e -> o) -> s -> Bool Source #

Sort by comparing the results of a given function applied to each element.