Reputation: 6612
I am trying to run an interactive command with haskell turtle library like this:
#!/usr/bin/env stack
-- stack --install-ghc runghc --package turtle
{-# LANGUAGE OverloadedStrings #-}
import Turtle
main = procs "python" [] empty
(I also tried shells function but it does not work either.) When I run it nothing hapens:
$ ./turtleTest.hs
$
But if I change "python" command to "ls" it works.
How can I run an interactive command like python repl with turtle library?
Upvotes: 3
Views: 415
Reputation: 66
{-# LANGUAGE OverloadedStrings #-}
import Turtle.Prelude (proc, procs, shell, shells)
main :: IO ()
main = do
procs "ls" [] mempty --(without ExitCode)
procs "ls" ["-la"] mempty --(without ExitCode)
proc "pwd" [] mempty --(with ExitCode)
proc "ls" ["-la"] mempty --(with ExitCode)
shells "ls -la" mempty --(without ExitCode)
shell "pwd" mempty --(with ExitCode)
shell "ls -la" mempty --(with ExitCode)
Upvotes: 0
Reputation: 673
Here's a complete working example extracted from comments. Tu run interactive process via Turtle you can do something like this:
#!/usr/bin/env stack
-- stack script --resolver lts-14.20 --package turtle --package process
{-# LANGUAGE OverloadedStrings #-}
import System.Process (callProcess)
import Turtle (sh, liftIO)
main :: IO ()
main = sh $ liftIO $ callProcess "python" []
Upvotes: 2