I have a file named "test.txt" with this text:
Good
Morning
Sir
and a file named "test.hs" with the following code:
module Main where
import System.IO
main :: IO ()
main = interact f
f :: String -> String
f s = head $ lines s
The following command...
cat test.txt | runhaskell test.hs
outputs
Good
However, I would like to explicitly pass parameters to runhaskell without relying on a file, like:
echo "Good\nMorning\nSir" | runhaskell test.hs
and also execute runhaskell with a literal string of Haskell code, like:
echo "Good\nMorning\nSir" | runhaskell "module Main where\nimport System.IO\nmain :: IO ()\nmain = interact f\nf :: String -> String\nf s = head $ lines s"
Is this technically possible ?