Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- data CodeStream m
- compile :: Monad m => Tournament t -> StreamEnv m -> CodeStream m
- codeSoFar :: CodeStream m -> Code
- createStreamEnv :: Monad m => PlayerCount -> StreamEnv m
- withGetStandings :: (Focus -> m Standings) -> StreamEnv m -> StreamEnv m
- debugCodeStream :: MonadCodeStream m c => m Code
- class (Monad m, MonadPrim RealWorld m, Monad c) => MonadCodeStream m c | m -> c where
- getCodeStream :: m (CodeStream c)
- putCodeStream :: CodeStream c -> m ()
- runCodeStreamEffect :: c a -> m a
- popCodeStream :: MonadCodeStream m c => m (Maybe TourneyOp)
- debugExecCompiler :: Tournament t -> Code
- compile_ :: Monad m => Tournament t -> Compiler m ()
Code streams
data CodeStream m Source #
Instances
Generic (CodeStream m) Source # | |
Defined in Tourney.VM.Compile Methods from :: CodeStream m -> Rep (CodeStream m) x Source # to :: Rep (CodeStream m) x -> CodeStream m Source # | |
type Rep (CodeStream m) Source # | |
Defined in Tourney.VM.Compile |
compile :: Monad m => Tournament t -> StreamEnv m -> CodeStream m Source #
codeSoFar :: CodeStream m -> Code Source #
createStreamEnv :: Monad m => PlayerCount -> StreamEnv m Source #
debugCodeStream :: MonadCodeStream m c => m Code Source #
Reading code off of a stream
class (Monad m, MonadPrim RealWorld m, Monad c) => MonadCodeStream m c | m -> c where Source #
Methods
getCodeStream :: m (CodeStream c) Source #
putCodeStream :: CodeStream c -> m () Source #
runCodeStreamEffect :: c a -> m a Source #
popCodeStream :: MonadCodeStream m c => m (Maybe TourneyOp) Source #
Get the next TourneyOp
from the code stream.
Debug
debugExecCompiler :: Tournament t -> Code Source #
compile_ :: Monad m => Tournament t -> Compiler m () Source #