在Haskell中执行多个命令的基本问题

在Haskell中执行多个命令的基本问题,haskell,haskell-stack,haskell-platform,Haskell,Haskell Stack,Haskell Platform,我的代码中包含以下内容: where launch :: MonadIO m => m (Maybe Text) launch = do line <- launchLine return $ lineToText <$> line launchLine :: MonadIO m => m (Maybe Line) launchLine = fold (inproc "juke" ["launch

我的代码中包含以下内容:

  where
    launch :: MonadIO m => m (Maybe Text)
    launch = do
        line <- launchLine
        return $ lineToText <$> line

    launchLine :: MonadIO m => m (Maybe Line)
    launchLine = fold (inproc "juke" ["launch", "--profile", "jukeplay", pack baseImage] mempty) $
        Fold selectLaunchName Nothing id
在哪里
launch::MonadIO m=>m(可能是文本)
发射=发射
线m(可能是线)
launchLine=折叠(在proc“juke”[“launch”、“--profile”、“jukeplay”、pack baseImage]mempty中)$
折叠选择LaunchName Nothing id
上面的线条很好用。我的问题是,我想在这个启动行之前执行另一个命令,所以它可能类似于:

  where
    launch :: MonadIO m => m (Maybe Text)
    launch = do
        line <- launchLine
        return $ lineToText <$> line

    launchLine :: MonadIO m => m (Maybe Line)
    launchLine = fold (inproc "juke" ["image", "copy", "jukebox:" <> pack baseImage, "local:", "--copy-aliases"] mempty) $
        Fold selectLaunchName Nothing id

    launchLine :: MonadIO m => m (Maybe Line)
    launchLine = fold (inproc "juke" ["launch", "--profile", "jukeplay", pack baseImage] mempty) $
        Fold selectLaunchName Nothing id
在哪里
launch::MonadIO m=>m(可能是文本)
发射=发射
线m(可能是线)
launchLine=fold(inproc“juke”[“image”,“copy”,“jukebox:“pack baseImage”,“local:”,“--copy alias”]mempty)$
折叠选择LaunchName Nothing id
launchLine::MonadIO m=>m(可能是行)
launchLine=折叠(在proc“juke”[“launch”、“--profile”、“jukeplay”、pack baseImage]mempty中)$
折叠选择LaunchName Nothing id
这显然是行不通的。我怎样才能做到这一点

我需要在执行“juke launch…”之前完成此“juke图像复制”


提前感谢您的帮助

您可以将一元操作与
(>>)
结合使用:

或者使用
do
语法,该语法表示
(>>)

例如:

launch :: MonadIO m => m (Maybe Text)
launch = do
    preLaunchLine
    line <- launchLine
    return $ lineToText <$> line

preLaunchLine :: MonadIO m => m (Maybe Line)
preLaunchLine = fold (inproc "juke" ["image", "copy", "jukebox:" <> pack baseImage, "local:", "--copy-aliases"] mempty) $
    Fold selectLaunchName Nothing id

launchLine :: MonadIO m => m (Maybe Line)
launchLine = fold (inproc "juke" ["launch", "--profile", "jukeplay", pack baseImage] mempty) $
    Fold selectLaunchName Nothing id
launch::MonadIO m=>m(可能是文本)
发射=发射
发射前
线m(可能是线)
preLaunchLine=fold(inproc“juke”[“image”,“copy”,“jukebox:“pack baseImage”,“local:”,“--copy alias”]mempty)$
折叠选择LaunchName Nothing id
launchLine::MonadIO m=>m(可能是行)
launchLine=折叠(在proc“juke”[“launch”、“--profile”、“jukeplay”、pack baseImage]mempty中)$
折叠选择LaunchName Nothing id

您想如何处理juke image copy的输出…?实际上什么都没有。这是一个shell命令,应该在第二个命令之前执行。这种情况下的输出不会被使用。我们不知道他是否想忽略中间结果though@JorgeAdriano当然有。在评论中,他们说“在这种情况下,
juke image copy…
]的输出将不会被使用”。@DanielWagner哦,我还没有看到他的答案,我的错@用户1858059您应该遵循警告中的建议(如果愿意,也可以使用
void
功能)
\act1 act2 -> do {act1; act2} :: Monad m => m a -> m b -> m b
launch :: MonadIO m => m (Maybe Text)
launch = do
    preLaunchLine
    line <- launchLine
    return $ lineToText <$> line

preLaunchLine :: MonadIO m => m (Maybe Line)
preLaunchLine = fold (inproc "juke" ["image", "copy", "jukebox:" <> pack baseImage, "local:", "--copy-aliases"] mempty) $
    Fold selectLaunchName Nothing id

launchLine :: MonadIO m => m (Maybe Line)
launchLine = fold (inproc "juke" ["launch", "--profile", "jukeplay", pack baseImage] mempty) $
    Fold selectLaunchName Nothing id