My goal is to pipe some steps for ghci
to run from a bash script and then exit cleanly. The commentary online says to use runhaskell
for this.
This is the command I'm trying to run:
ghci> import System.Random
ghci> random (mkStdGen 100) :: (Int, StdGen)
With expected result similar to:
(-3633736515773289454,693699796 2103410263)
When I drop this into a file randomtest.hs
and execute it with runhaskell
I get the following error:.
randomtest.hs:3:1: error:
Invalid type signature: random (mkStdGen 100) :: ...
Should be of form <variable> :: <type>
It seems I can't use the runhaskell
method to blindly execute ghci
inputs.
Now the way to work around this is to add extra commands to the file that is passed to runhaskell
:
main = do print (random (mkStdGen 100) :: (Int, StdGen))
My goal is to automate the running of ghci work for a haskell course I'm using. I want to be able to run the ghci command from a bash script - in the format that ghci expects, and have it cleanly exit from ghci (or whatever runs it).
My question is: Is there a way to script a ghci session?