Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Tourney.Algebra.Builder
Synopsis
- data Builder t r a
- class AsSteps a r where
- type Steps = Builder TMany
- round_ :: forall a m. (MonadRounds m, AsRound a ()) => a -> m ()
- rounds_ :: AsRound r () => [r] -> Steps s ()
- asRound :: Round r a -> Round r a
- class AsRound a r where
- type Round = Builder TOne
- match :: AsMatch m => m -> Round r ()
- class AsMatch m where
- list :: Foldable f => f a -> Builder t r a
- overlaysBy :: (Foldable f, Merge t) => (a -> x) -> f (Builder t x a) -> Builder t r [x]
- overlays :: (Foldable f, Merge t) => f (Builder t a a) -> Builder t r [a]
- overlays_ :: (Foldable f, Merge t) => f (Builder t a a) -> Builder t r ()
- getStandings :: Merge t => Builder t () Standings
- getPlayerCount :: Merge t => Builder t () PlayerCount
- withFocus :: Merge t => Slot -> Int -> Builder t a a -> Builder ('TMod t) r ()
- withFocii :: Merge t => (Focus -> [Focus]) -> Builder t a a -> Builder ('TMod t) r ()
- withOffset :: Merge t => Int -> Builder t a a -> Builder ('TMod t) r ()
- divideInto :: Int -> Steps () () -> Steps () ()
- foldAround :: Int -> [Slot] -> [Match]
- foldAroundMidpoint :: [Slot] -> [Match]
- swaps :: Merge t => Builder t a a -> Builder t r ()
- points :: Merge t => Builder t () () -> Builder t r ()
- barrier :: Merge t => Builder t () () -> Builder t r ()
- inspect :: (Merge t, Merge i) => Inspect i a -> Builder i r r -> Builder t () a
- execBuilder :: Merge t => (a -> r) -> Builder t r a -> Tournament t
- execSteps :: (a -> r) -> Steps r a -> Tournament TMany
- execRound :: (a -> r) -> Round r a -> Tournament TOne
- runSteps :: (a -> r) -> Steps r a -> ([r], Tournament TMany)
- runRound :: (a -> r) -> Round r a -> ([r], Tournament TOne)
- getAccum :: Merge t => Builder t r (Tournament t)
Documentation
Instances
MonadFail (Builder t r) Source # | |
Applicative (Builder t r) Source # | |
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 # | |
Monad (Builder t r) Source # | |
(x ~ (), r ~ r') => AsRound (Round r x) r' Source # | |
a ~ () => AsSteps (Steps r a) r Source # | |
Overloaded constructors
Steps
class AsSteps a r where Source #
Instances
t ~ 'TMany => AsSteps (Tournament t) r Source # | |
Defined in Tourney.Algebra.Builder Methods steps :: Tournament t -> Steps r () Source # | |
AsRound a () => AsSteps (Vector a) r Source # | |
AsRound a () => AsSteps [a] r Source # | |
Defined in Tourney.Algebra.Builder | |
a ~ () => AsSteps (Steps r a) r Source # | |
(AsSteps a r, r ~ ()) => AsSteps (PlayerCount -> a) r Source # | |
Defined in Tourney.Algebra.Builder Methods steps :: (PlayerCount -> a) -> Steps r () Source # | |
(AsSteps a r, r ~ ()) => AsSteps (Standings -> a) r Source # | |
Rounds
class AsRound a r where Source #
Instances
AsRound Match r Source # | |
t ~ 'TOne => AsRound (Tournament t) r Source # | |
Defined in Tourney.Algebra.Builder Methods toRound :: Tournament t -> Round r () Source # | |
(AsRound a r, r ~ ()) => AsRound (Vector a) r Source # | |
(AsRound a r, r ~ ()) => AsRound [a] r Source # | |
Defined in Tourney.Algebra.Builder | |
(x ~ (), r ~ r') => AsRound (Round r x) r' Source # | |
(AsRound a r, r ~ ()) => AsRound (PlayerCount -> a) r Source # | |
Defined in Tourney.Algebra.Builder Methods toRound :: (PlayerCount -> a) -> Round r () Source # | |
(AsRound a r, r ~ ()) => AsRound (Standings -> a) 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
.
Matches
Basic syntax
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.
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 #
getAccum :: Merge t => Builder t r (Tournament t) Source #