journeyman-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Tourney.Algebra.Builder

Synopsis

Documentation

data Builder t r a Source #

Instances

Instances details
MonadFail (Builder t r) Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

fail :: String -> Builder t r a Source #

Applicative (Builder t r) Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

pure :: a -> Builder t r a Source #

(<*>) :: Builder t r (a -> b) -> Builder t r a -> Builder t r b Source #

liftA2 :: (a -> b -> c) -> Builder t r a -> Builder t r b -> Builder t r c Source #

(*>) :: Builder t r a -> Builder t r b -> Builder t r b Source #

(<*) :: Builder t r a -> Builder t r b -> Builder t r a Source #

Functor (Builder t r) Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

fmap :: (a -> b) -> Builder t r a -> Builder t r b Source #

(<$) :: a -> Builder t r b -> Builder t r a Source #

Monad (Builder t r) Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

(>>=) :: Builder t r a -> (a -> Builder t r b) -> Builder t r b Source #

(>>) :: Builder t r a -> Builder t r b -> Builder t r b Source #

return :: a -> Builder t r a Source #

(x ~ (), r ~ r') => AsRound (Round r x) r' Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toRound :: Round r x -> Round r' () Source #

a ~ () => AsSteps (Steps r a) r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

steps :: Steps r a -> Steps r () Source #

Overloaded constructors

Steps

class AsSteps a r where Source #

Values that have simple Steps representations. Think of this as an overloaded Steps constructor.

Methods

steps :: a -> Steps r () Source #

Instances

Instances details
t ~ 'TMany => AsSteps (Tournament t) r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

steps :: Tournament t -> Steps r () Source #

AsRound a () => AsSteps (Vector a) r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

steps :: Vector a -> Steps r () Source #

AsRound a () => AsSteps [a] r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

steps :: [a] -> Steps r () Source #

a ~ () => AsSteps (Steps r a) r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

steps :: Steps r a -> Steps r () Source #

(AsSteps a r, r ~ ()) => AsSteps (PlayerCount -> a) r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

steps :: (PlayerCount -> a) -> Steps r () Source #

(AsSteps a r, r ~ ()) => AsSteps (Standings -> a) r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

steps :: (Standings -> a) -> Steps r () Source #

type Steps = Builder TMany Source #

A monad to build tournaments over steps (See (***)). Operations in this monad create rounds. See Round for a builder monad to create rounds.

round_ :: forall a m. (MonadRounds m, AsRound a ()) => a -> m () Source #

Add a round to steps

rounds_ :: AsRound r () => [r] -> Steps s () Source #

Add some rounds to steps

asRound :: Round r a -> Round r a Source #

Rounds

class AsRound a r where Source #

Methods

toRound :: a -> Round r () Source #

Instances

Instances details
AsRound Match r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toRound :: Match -> Round r () Source #

t ~ 'TOne => AsRound (Tournament t) r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toRound :: Tournament t -> Round r () Source #

(AsRound a r, r ~ ()) => AsRound (Vector a) r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toRound :: Vector a -> Round r () Source #

(AsRound a r, r ~ ()) => AsRound [a] r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toRound :: [a] -> Round r () Source #

(x ~ (), r ~ r') => AsRound (Round r x) r' Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toRound :: Round r x -> Round r' () Source #

(AsRound a r, r ~ ()) => AsRound (PlayerCount -> a) r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toRound :: (PlayerCount -> a) -> Round r () Source #

(AsRound a r, r ~ ()) => AsRound (Standings -> a) r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toRound :: (Standings -> a) -> Round r () Source #

type Round = Builder TOne Source #

A monad to build tournaments over matches. For convenience, this monad behaves like a list monad, where the inner list is ultimately combined by overlay.

match :: AsMatch m => m -> Round r () Source #

Add a match to the round

Matches

class AsMatch m where Source #

Methods

toMatch :: m -> Match Source #

Instances

Instances details
AsMatch Match Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toMatch :: Match -> Match Source #

(x ~ Slot, y ~ Slot) => AsMatch (x, y) Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toMatch :: (x, y) -> Match Source #

Basic syntax

list :: Foldable f => f a -> Builder t r a Source #

Lift a list into a Round for iteration. The underlying effect on the Round is to overlay the iterated elements

overlaysBy :: (Foldable f, Merge t) => (a -> x) -> f (Builder t x a) -> Builder t r [x] Source #

Overlay a collection of builders

overlays :: (Foldable f, Merge t) => f (Builder t a a) -> Builder t r [a] Source #

Overlay a collection of builders

overlays_ :: (Foldable f, Merge t) => f (Builder t a a) -> Builder t r () Source #

Overlay a collection of builders

getStandings :: Merge t => Builder t () Standings Source #

Retrieve the current standings

Warning: this operation will have the effect of segmenting the tournament into two sections, as a tournament runner cannot continue past this point without first having the standings.

getPlayerCount :: Merge t => Builder t () PlayerCount Source #

Retrieve the current player count

withFocus :: Merge t => Slot -> Int -> Builder t a a -> Builder ('TMod t) r () Source #

Set the focus of the inner builder

withFocii :: Merge t => (Focus -> [Focus]) -> Builder t a a -> Builder ('TMod t) r () Source #

Set the focii of the inner builder

withOffset :: Merge t => Int -> Builder t a a -> Builder ('TMod t) r () Source #

Set the offset of the inner builder

divideInto :: Int -> Steps () () -> Steps () () Source #

Given a denominator n and a builder, split the tournament into n sub-tournaments and run the builder on each

foldAround :: Int -> [Slot] -> [Match] Source #

Fold a list of players together around a midpoint of the list.

foldAroundMidpoint :: [Slot] -> [Match] Source #

Fold a list of players together around _the_ midpoint of the list. You should ensure the input list has an even number of players.

swaps :: Merge t => Builder t a a -> Builder t r () Source #

points :: Merge t => Builder t () () -> Builder t r () Source #

barrier :: Merge t => Builder t () () -> Builder t r () Source #

Reduction back into a Tournament

inspect :: (Merge t, Merge i) => Inspect i a -> Builder i r r -> Builder t () a Source #

Inspect the inner builder, for, e.g., matches

execBuilder :: Merge t => (a -> r) -> Builder t r a -> Tournament t Source #

execSteps :: (a -> r) -> Steps r a -> Tournament TMany Source #

execRound :: (a -> r) -> Round r a -> Tournament TOne Source #

runSteps :: (a -> r) -> Steps r a -> ([r], Tournament TMany) Source #

runRound :: (a -> r) -> Round r a -> ([r], Tournament TOne) Source #

getAccum :: Merge t => Builder t r (Tournament t) Source #