-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename Server -> Env; consolidate related modules
- Loading branch information
Showing
12 changed files
with
87 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Ensemble | ||
( module Ensemble.API | ||
, module Ensemble.Server | ||
, module Ensemble.Env | ||
) where | ||
|
||
import Ensemble.API | ||
import Ensemble.Server | ||
import Ensemble.Env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
|
||
module Ensemble.Env where | ||
|
||
import Clap.Interface.Host | ||
import Control.Concurrent | ||
import Control.Monad.Reader | ||
import Data.Aeson (Value) | ||
import Data.IORef | ||
import Ensemble.Config | ||
import Ensemble.Engine | ||
import Ensemble.Sequencer | ||
|
||
newtype Ensemble a = Ensemble { unEnsemble :: ReaderT Env IO a } | ||
deriving newtype (Monad, Applicative, Functor, MonadReader Env, MonadIO) | ||
|
||
data Env = Env | ||
{ env_config :: Config | ||
, env_sequencer :: Sequencer | ||
, env_engine :: Engine | ||
, env_messageChannel :: Chan Value | ||
, env_pluginGuiThreadId :: IORef (Maybe ThreadId) | ||
} | ||
|
||
createEnv :: Config -> IO Env | ||
createEnv config = do | ||
sequencer <- createSequencer | ||
engine <- createEngine defaultHostConfig | ||
messageChannel <- newChan | ||
pluginGuiThreadId <- newIORef Nothing | ||
pure $ Env | ||
{ env_config = config | ||
, env_sequencer = sequencer | ||
, env_engine = engine | ||
, env_messageChannel = messageChannel | ||
, env_pluginGuiThreadId = pluginGuiThreadId | ||
} | ||
|
||
runEnsemble :: Env -> Ensemble a -> IO a | ||
runEnsemble env action = runReaderT (unEnsemble action) env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.