Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Tourney.Algebra.Unified
Synopsis
- data Tournament :: Depth -> Type where
- One :: Match -> Tournament 'TOne
- Empty :: Tournament t
- Modify :: Mod -> Tournament t -> Tournament (TMod t)
- Overlay :: Tournament a -> Tournament a -> Tournament a
- Sequence :: (KnownDepth a, KnownDepth b) => Tournament a -> Tournament b -> Tournament TMany
- Sort :: SortMethod -> Tournament t -> Tournament t
- ByPlayerCount :: (PlayerCount -> Tournament t) -> Tournament t
- ByStandings :: (Standings -> Tournament t) -> Tournament t
- LiftTOne :: Tournament TOne -> Tournament TMany
- LiftTMod :: KnownDepth t => Tournament (TMod t) -> Tournament TMany
- data Mod
- (+++) :: Tournament a -> Tournament a -> Tournament a
- overlay :: Foldable f => f (Tournament a) -> Tournament a
- (***) :: forall a b. (KnownDepth a, KnownDepth b) => Tournament a -> Tournament b -> Tournament TMany
- sequence :: (Foldable f, KnownDepth a) => f (Tournament a) -> Tournament TMany
- data SortMethod
- data Sorter = Sorter {
- sorterFocus :: !Focus
- sorterMethod :: !SortMethod
- data Focus = Focus {
- focusStart :: !Slot
- focusLength :: !Int
- data Depth
- class Typeable d => KnownDepth (d :: Depth) where
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 |
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 |
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 |
LiftTMod :: KnownDepth t => Tournament (TMod t) -> Tournament TMany | Lift a modified round of a tournament into having a depth |
Instances
Monoid (Tournament t) Source # | |
Defined in Tourney.Algebra.Unified Methods mempty :: Tournament t Source # mappend :: Tournament t -> Tournament t -> Tournament t Source # mconcat :: [Tournament t] -> Tournament t Source # | |
Semigroup (Tournament t) Source # | |
Defined in Tourney.Algebra.Unified Methods (<>) :: Tournament t -> Tournament t -> Tournament t Source # sconcat :: NonEmpty (Tournament t) -> Tournament t Source # stimes :: Integral b => b -> Tournament t -> Tournament t Source # | |
Show (Tournament t) Source # | |
Defined in Tourney.Algebra.Unified | |
t ~ 'TOne => AsRound (Tournament t) r Source # | |
Defined in Tourney.Algebra.Builder Methods toRound :: Tournament t -> Round r () Source # | |
t ~ 'TMany => AsSteps (Tournament t) r Source # | |
Defined in Tourney.Algebra.Builder Methods steps :: Tournament t -> Steps r () Source # |
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
.
sequence :: (Foldable f, KnownDepth a) => f (Tournament a) -> Tournament TMany Source #
Extra Types
data SortMethod Source #
Constructors
WinnerTakesHigh | |
PointsAward | Award points and use that to sort the results in the end |
Instances
Show SortMethod Source # | |
Defined in Tourney.Common | |
Default SortMethod Source # | |
Defined in Tourney.Common Methods def :: SortMethod Source # | |
Eq SortMethod Source # | |
Defined in Tourney.Common Methods (==) :: SortMethod -> SortMethod -> Bool Source # (/=) :: SortMethod -> SortMethod -> Bool Source # | |
Ord SortMethod Source # | |
Defined in Tourney.Common Methods compare :: SortMethod -> SortMethod -> Ordering Source # (<) :: SortMethod -> SortMethod -> Bool Source # (<=) :: SortMethod -> SortMethod -> Bool Source # (>) :: SortMethod -> SortMethod -> Bool Source # (>=) :: SortMethod -> SortMethod -> Bool Source # max :: SortMethod -> SortMethod -> SortMethod Source # min :: SortMethod -> SortMethod -> SortMethod Source # |
Constructors
Sorter | |
Fields
|
Instances
Generic Sorter Source # | |
Show Sorter Source # | |
Eq Sorter Source # | |
type Rep Sorter Source # | |
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))) |
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
Generic Focus Source # | |
Show Focus Source # | |
Eq Focus Source # | |
Ord Focus Source # | |
Defined in Tourney.Common | |
type Rep Focus Source # | |
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))) |
The depth of a tournament. Since we only care about distinguishing single rounds from sequences of rounds, that is the only information stored here.
class Typeable d => KnownDepth (d :: Depth) where Source #
Instances
KnownDepth 'TMany Source # | |
KnownDepth 'TOne Source # | |
KnownDepth d => KnownDepth ('TMod d) Source # | |