Implement DependencyRunner for MapComp
This commit is contained in:
parent
53e9598d22
commit
d3b32398b5
|
@ -1,5 +1,7 @@
|
|||
module DependencyRunner
|
||||
( runDeps
|
||||
( DepRunM
|
||||
, runDeps
|
||||
, runDepRunM
|
||||
) where
|
||||
|
||||
import Types (Value(..), Valuable(..))
|
||||
|
@ -9,7 +11,7 @@ import Evaluation.FunctionIO
|
|||
|
||||
import Data.Map (Map)
|
||||
import qualified Data.Map as M
|
||||
import Control.Monad.State (MonadState, MonadIO, StateT, runState, put, get, modify, liftIO)
|
||||
import Control.Monad.State (MonadState, MonadIO, StateT, evalStateT, get, modify, liftIO)
|
||||
|
||||
newtype DepRunM a = DepRunM { unDepRunM :: StateT (Map Int Value) IO a }
|
||||
deriving (Functor, Applicative, Monad, MonadIO, MonadState (Map Int Value))
|
||||
|
@ -17,6 +19,9 @@ newtype DepRunM a = DepRunM { unDepRunM :: StateT (Map Int Value) IO a }
|
|||
runDeps :: [Dependency] -> DepRunM ()
|
||||
runDeps = mapM_ runDep
|
||||
|
||||
runDepRunM :: DepRunM a -> IO a
|
||||
runDepRunM m = evalStateT (unDepRunM m) M.empty
|
||||
|
||||
runDep :: Dependency -> DepRunM ()
|
||||
runDep (Dependency a action b) = do
|
||||
input <- getTokenValue a
|
||||
|
@ -91,4 +96,11 @@ runAction action input = case action of
|
|||
_ ->
|
||||
error "unexpected"
|
||||
MapComp subDeps innerInput innerOutput ->
|
||||
undefined
|
||||
case input of
|
||||
List vs ->
|
||||
(List <$>) $ flip mapM vs $ \v -> do
|
||||
putTokenValue innerInput v
|
||||
runDeps subDeps
|
||||
getTokenValue innerOutput
|
||||
_ ->
|
||||
error "unexpected"
|
||||
|
|
Loading…
Reference in New Issue