hgeometry-combinatorial
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageGHC2021

HGeometry.Indexed

Description

Things that have an index.

Synopsis

Documentation

class HasIndex a where Source #

Types that have an index.

Methods

sosIndex :: a -> Index Source #

Get the index of a given a

Instances

Instances details
HasIndex (WithIndex a) Source # 
Instance details

Defined in HGeometry.Indexed

type Index = Int Source #

A type of Indices

data WithIndex a Source #

Associate a value of type a with an Index.

The indices are assumed to be unique, so comparisons are just based on indices

Constructors

WithIndex !Index a 

Instances

Instances details
NFData a => NFData (WithIndex a) Source # 
Instance details

Defined in HGeometry.Indexed

Methods

rnf :: WithIndex a -> () Source #

Generic (WithIndex a) Source # 
Instance details

Defined in HGeometry.Indexed

Associated Types

type Rep (WithIndex a) 
Instance details

Defined in HGeometry.Indexed

type Rep (WithIndex a) = D1 ('MetaData "WithIndex" "HGeometry.Indexed" "hgeometry-combinatorial-1.0.0.0-inplace" 'False) (C1 ('MetaCons "WithIndex" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Index) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

from :: WithIndex a -> Rep (WithIndex a) x Source #

to :: Rep (WithIndex a) x -> WithIndex a Source #

Show a => Show (WithIndex a) Source # 
Instance details

Defined in HGeometry.Indexed

Eq (WithIndex a) Source # 
Instance details

Defined in HGeometry.Indexed

Ord (WithIndex a) Source # 
Instance details

Defined in HGeometry.Indexed

HasIndex (WithIndex a) Source # 
Instance details

Defined in HGeometry.Indexed

Field1 (WithIndex a) (WithIndex b) a b Source # 
Instance details

Defined in HGeometry.Indexed

Methods

_1 :: Lens (WithIndex a) (WithIndex b) a b Source #

type Rep (WithIndex a) Source # 
Instance details

Defined in HGeometry.Indexed

type Rep (WithIndex a) = D1 ('MetaData "WithIndex" "HGeometry.Indexed" "hgeometry-combinatorial-1.0.0.0-inplace" 'False) (C1 ('MetaCons "WithIndex" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Index) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

theValue :: forall a b f. Functor f => (a -> f b) -> WithIndex a -> f (WithIndex b) Source #

Lens to manipulate the value of the WithIndex

labelWithIndex :: Traversable t => t a -> t (WithIndex a) Source #

Label each element with its index.

labelWith :: Traversable t => (Index -> a -> b) -> t a -> t b Source #

Label each element with its index using the given labelling function.

labelWith' :: Traversable t => (Index -> a -> b) -> t a -> (t b, Int) Source #

Label each element with its index using the given labelling function. Returns the new collection as well as its size.