journeyman-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Tourney.Algebra.Unified

Synopsis

Base eDSL

The core primitives and syntax of the journeyman tournament eDSL are defined here. For how these values can be transformed into a flattened stream of rounds, see Tourney.Stream

data Tournament :: Depth -> Type where Source #

A description of a tournament. The type-parameter gives an upper-bound on how many rounds this tournament has. It also ensures that the spine of a tournament is static, regardless of use of constructors such as ByStandings, that enable creating tournaments that depend on match results that are not yet known. Intuitively if you have a tournament with depth TMany, it means it contains multiple rounds, whereas if you have a tournament with depth TOne, then it is only one round.

Constructors

One :: Match -> Tournament 'TOne 
Empty :: Tournament t 
Modify :: Mod -> Tournament t -> Tournament (TMod t)

Modify a tournament by some Mod, such as setting the focus.

Overlay :: Tournament a -> Tournament a -> Tournament a

Overlay two tournaments, to describe running two sub-tournaments in parallel. The depth of the tournaments must be the same

Sequence :: (KnownDepth a, KnownDepth b) => Tournament a -> Tournament b -> Tournament TMany

Sequence two tournaments one after the other. The resulting tournament has a depth TMany which restricts what functions are able to manipulate it.

Sort :: SortMethod -> Tournament t -> Tournament t

Sort the inner tournament by some sorting method

ByPlayerCount :: (PlayerCount -> Tournament t) -> Tournament t

Depend on the player count to produce an inner tournament

ByStandings :: (Standings -> Tournament t) -> Tournament t

Depend on the current standings, at the outset of the current round, to run the tournament.

LiftTOne :: Tournament TOne -> Tournament TMany

Lift a single round of a tournament into having a depth TMany

LiftTMod :: KnownDepth t => Tournament (TMod t) -> Tournament TMany

Lift a modified round of a tournament into having a depth TMany

Instances

Instances details
Monoid (Tournament t) Source # 
Instance details

Defined in Tourney.Algebra.Unified

Semigroup (Tournament t) Source # 
Instance details

Defined in Tourney.Algebra.Unified

Show (Tournament t) Source # 
Instance details

Defined in Tourney.Algebra.Unified

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

Defined in Tourney.Algebra.Builder

Methods

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

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

Defined in Tourney.Algebra.Builder

Methods

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

data Mod Source #

Constructors

SetFocus !(Focus -> [Focus]) 
SetOffset !Int 

Operators

Overlays of tournaments

The verb overlay comes from algebraic graph theory, and means to combine two graphs by simply having them coexist in the same graph; no actual edges are drawn.

(+++) :: Tournament a -> Tournament a -> Tournament a infixl 2 Source #

Overlay two tournaments. See Overlay.

overlay :: Foldable f => f (Tournament a) -> Tournament a Source #

Overlay an arbitrary number of tournaments.

Sequencing tournaments

Sequencing means to connect two tournaments by having one happen before the other. A round means a single step of a tournament such as a group of matches.

(***) :: forall a b. (KnownDepth a, KnownDepth b) => Tournament a -> Tournament b -> Tournament TMany infixl 1 Source #

Sequence two tournaments, running them one after the other. See Sequence.

Extra Types

data SortMethod Source #

Constructors

WinnerTakesHigh 
PointsAward

Award points and use that to sort the results in the end

data Sorter Source #

Constructors

Sorter 

Instances

Instances details
Generic Sorter Source # 
Instance details

Defined in Tourney.Common

Associated Types

type Rep Sorter :: Type -> Type Source #

Show Sorter Source # 
Instance details

Defined in Tourney.Common

Eq Sorter Source # 
Instance details

Defined in Tourney.Common

type Rep Sorter Source # 
Instance details

Defined in Tourney.Common

type Rep Sorter = D1 ('MetaData "Sorter" "Tourney.Common" "journeyman-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Sorter" 'PrefixI 'True) (S1 ('MetaSel ('Just "sorterFocus") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Focus) :*: S1 ('MetaSel ('Just "sorterMethod") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SortMethod)))

data Focus Source #

The focus of a tournament over a sorting network. A good intuition is that a Focus is basically an array slice over a round.

Constructors

Focus 

Fields

Instances

Instances details
Generic Focus Source # 
Instance details

Defined in Tourney.Common

Associated Types

type Rep Focus :: Type -> Type Source #

Methods

from :: Focus -> Rep Focus x Source #

to :: Rep Focus x -> Focus Source #

Show Focus Source # 
Instance details

Defined in Tourney.Common

Eq Focus Source # 
Instance details

Defined in Tourney.Common

Methods

(==) :: Focus -> Focus -> Bool Source #

(/=) :: Focus -> Focus -> Bool Source #

Ord Focus Source # 
Instance details

Defined in Tourney.Common

type Rep Focus Source # 
Instance details

Defined in Tourney.Common

type Rep Focus = D1 ('MetaData "Focus" "Tourney.Common" "journeyman-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Focus" 'PrefixI 'True) (S1 ('MetaSel ('Just "focusStart") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Slot) :*: S1 ('MetaSel ('Just "focusLength") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)))

data Depth Source #

The depth of a tournament. Since we only care about distinguishing single rounds from sequences of rounds, that is the only information stored here.

Constructors

TOne 
TMany 
TMod Depth 

class Typeable d => KnownDepth (d :: Depth) where Source #

Methods

depthVal :: proxy d -> Depth Source #

Instances

Instances details
KnownDepth 'TMany Source # 
Instance details

Defined in Tourney.Algebra.Unified

Methods

depthVal :: proxy 'TMany -> Depth Source #

KnownDepth 'TOne Source # 
Instance details

Defined in Tourney.Algebra.Unified

Methods

depthVal :: proxy 'TOne -> Depth Source #

KnownDepth d => KnownDepth ('TMod d) Source # 
Instance details

Defined in Tourney.Algebra.Unified

Methods

depthVal :: proxy ('TMod d) -> Depth Source #