journeyman-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Tourney.VM.Compile

Description

Compile a tournament into a stream of operations that can have a straightforward interpreter implementation. Compilation relies on having an underlying monad that can manipulate a stream of code.

This may seem overkill but it greatly simplifies things in the implementation. The initial implementation generated a stream of rounds from a tournament directly, but the stream of rounds had to actually be a stream of stream of rounds, which had to be a stream of stream of streams of matches. This is ultimately because the Tournament language allows the ByStandings constructor anywhere, and because it can split or interleave tournaments at will. While I could just flatten all matches within a round, that feels antithetical to the goal of maximising how much of a tournament can be statically analysed.

Synopsis

Code streams

data CodeStream m Source #

Instances

Instances details
Generic (CodeStream m) Source # 
Instance details

Defined in Tourney.VM.Compile

Associated Types

type Rep (CodeStream m) :: Type -> Type Source #

Methods

from :: CodeStream m -> Rep (CodeStream m) x Source #

to :: Rep (CodeStream m) x -> CodeStream m Source #

type Rep (CodeStream m) Source # 
Instance details

Defined in Tourney.VM.Compile

type Rep (CodeStream m)

Reading code off of a stream

class (Monad m, MonadPrim RealWorld m, Monad c) => MonadCodeStream m c | m -> c where Source #

popCodeStream :: MonadCodeStream m c => m (Maybe TourneyOp) Source #

Get the next TourneyOp from the code stream.

Debug

compile_ :: Monad m => Tournament t -> Compiler m () Source #