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

HGeometry.Combinatorial.Util

Description

Some basic types, mostly strict triples and pairs.

Synopsis

Strict Triples

data STR a b c Source #

strict triple

Constructors

STR !a !b !c 

Instances

Instances details
Functor (STR a b) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

fmap :: (a0 -> b0) -> STR a b a0 -> STR a b b0 #

(<$) :: a0 -> STR a b b0 -> STR a b a0 #

(NFData a, NFData b, NFData c) => NFData (STR a b c) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

rnf :: STR a b c -> () #

(Semigroup a, Semigroup b, Semigroup c, Monoid a, Monoid b, Monoid c) => Monoid (STR a b c) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

mempty :: STR a b c #

mappend :: STR a b c -> STR a b c -> STR a b c #

mconcat :: [STR a b c] -> STR a b c #

(Semigroup a, Semigroup b, Semigroup c) => Semigroup (STR a b c) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

(<>) :: STR a b c -> STR a b c -> STR a b c #

sconcat :: NonEmpty (STR a b c) -> STR a b c #

stimes :: Integral b0 => b0 -> STR a b c -> STR a b c #

Generic (STR a b c) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Associated Types

type Rep (STR a b c) 
Instance details

Defined in HGeometry.Combinatorial.Util

type Rep (STR a b c) = D1 ('MetaData "STR" "HGeometry.Combinatorial.Util" "hgeometry-combinatorial-1.0.0.0-inplace" 'False) (C1 ('MetaCons "STR" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 c))))

Methods

from :: STR a b c -> Rep (STR a b c) x #

to :: Rep (STR a b c) x -> STR a b c #

(Show a, Show b, Show c) => Show (STR a b c) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

showsPrec :: Int -> STR a b c -> ShowS #

show :: STR a b c -> String #

showList :: [STR a b c] -> ShowS #

(Eq a, Eq b, Eq c) => Eq (STR a b c) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

(==) :: STR a b c -> STR a b c -> Bool #

(/=) :: STR a b c -> STR a b c -> Bool #

(Ord a, Ord b, Ord c) => Ord (STR a b c) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

compare :: STR a b c -> STR a b c -> Ordering #

(<) :: STR a b c -> STR a b c -> Bool #

(<=) :: STR a b c -> STR a b c -> Bool #

(>) :: STR a b c -> STR a b c -> Bool #

(>=) :: STR a b c -> STR a b c -> Bool #

max :: STR a b c -> STR a b c -> STR a b c #

min :: STR a b c -> STR a b c -> STR a b c #

Field1 (STR a b c) (STR d b c) a d Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

_1 :: Lens (STR a b c) (STR d b c) a d Source #

Field2 (STR a b c) (STR a d c) b d Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

_2 :: Lens (STR a b c) (STR a d c) b d Source #

Field3 (STR a b c) (STR a b d) c d Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

_3 :: Lens (STR a b c) (STR a b d) c d Source #

type Rep (STR a b c) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

type Rep (STR a b c) = D1 ('MetaData "STR" "HGeometry.Combinatorial.Util" "hgeometry-combinatorial-1.0.0.0-inplace" 'False) (C1 ('MetaCons "STR" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 c))))

type Three = V3 Source #

Strict Triple with all items the same

pattern Three :: a -> a -> a -> Three a Source #

Pattern synonym for strict triples.

uniqueTriplets :: Foldable f => f a -> [Three a] Source #

Generate All unique unordered triplets.

>>> mapM_ print $ uniqueTriplets "abcd"
V3 'a' 'b' 'c'
V3 'a' 'b' 'd'
V3 'a' 'c' 'd'
V3 'b' 'c' 'd'

Strict Pairs

data SP a b Source #

Strict pair

Constructors

SP !a !b 

Instances

Instances details
Bifunctor SP Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

bimap :: (a -> b) -> (c -> d) -> SP a c -> SP b d #

first :: (a -> b) -> SP a c -> SP b c #

second :: (b -> c) -> SP a b -> SP a c #

Functor (SP a) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

fmap :: (a0 -> b) -> SP a a0 -> SP a b #

(<$) :: a0 -> SP a b -> SP a a0 #

(NFData a, NFData b) => NFData (SP a b) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

rnf :: SP a b -> () #

(Semigroup a, Semigroup b, Monoid a, Monoid b) => Monoid (SP a b) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

mempty :: SP a b #

mappend :: SP a b -> SP a b -> SP a b #

mconcat :: [SP a b] -> SP a b #

(Semigroup a, Semigroup b) => Semigroup (SP a b) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

(<>) :: SP a b -> SP a b -> SP a b #

sconcat :: NonEmpty (SP a b) -> SP a b #

stimes :: Integral b0 => b0 -> SP a b -> SP a b #

Generic (SP a b) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Associated Types

type Rep (SP a b) 
Instance details

Defined in HGeometry.Combinatorial.Util

type Rep (SP a b) = D1 ('MetaData "SP" "HGeometry.Combinatorial.Util" "hgeometry-combinatorial-1.0.0.0-inplace" 'False) (C1 ('MetaCons "SP" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b)))

Methods

from :: SP a b -> Rep (SP a b) x #

to :: Rep (SP a b) x -> SP a b #

(Show a, Show b) => Show (SP a b) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

showsPrec :: Int -> SP a b -> ShowS #

show :: SP a b -> String #

showList :: [SP a b] -> ShowS #

(Eq a, Eq b) => Eq (SP a b) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

(==) :: SP a b -> SP a b -> Bool #

(/=) :: SP a b -> SP a b -> Bool #

(Ord a, Ord b) => Ord (SP a b) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

compare :: SP a b -> SP a b -> Ordering #

(<) :: SP a b -> SP a b -> Bool #

(<=) :: SP a b -> SP a b -> Bool #

(>) :: SP a b -> SP a b -> Bool #

(>=) :: SP a b -> SP a b -> Bool #

max :: SP a b -> SP a b -> SP a b #

min :: SP a b -> SP a b -> SP a b #

Field1 (SP a b) (SP c b) a c Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

_1 :: Lens (SP a b) (SP c b) a c Source #

Field2 (SP a b) (SP a c) b c Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

Methods

_2 :: Lens (SP a b) (SP a c) b c Source #

type Rep (SP a b) Source # 
Instance details

Defined in HGeometry.Combinatorial.Util

type Rep (SP a b) = D1 ('MetaData "SP" "HGeometry.Combinatorial.Util" "hgeometry-combinatorial-1.0.0.0-inplace" 'False) (C1 ('MetaCons "SP" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b)))

type Two = V2 Source #

  • Strict pair whose elements are of the same type.

Strict pair with both items the same

pattern Two :: a -> a -> Two a Source #

Pattern synonym for strict pairs.

uniquePairs :: Foldable f => f a -> [Two a] Source #

Given a list xs, generate all unique (unordered) pairs.

>>> mapM_ print $ uniquePairs "abcde"
V2 'a' 'b'
V2 'a' 'c'
V2 'a' 'd'
V2 'a' 'e'
V2 'b' 'c'
V2 'b' 'd'
V2 'b' 'e'
V2 'c' 'd'
V2 'c' 'e'
V2 'd' 'e'

nonEmptyTails :: [a] -> [[a]] Source #

A version of List.tails in which we remove the emptylist