GHCi: scripting and multiline input
Vivian McPhail
haskell.vivian.mcphail at gmail.com
Tue Sep 14 00:23:23 EDT 2010
Hi,
I am attempting to mimic matlab/octave using ghci, including a facility for
updateable graphs of data.
1) It would be nice to be able to load a script of commands from the prompt
\begin{file}
script Sine where
import "hmatrix" Numeric.Vector
import "plot" Graphics.Rendering.Plot
let ts = linspace 1000 (0,1 :: Double)
let ss = sin (15*2*pi*ts) -- 15 Hz sine wave
figure1 <- display $ plot (ts,[line ss blue])
\end{file}
The idea is (apart from the import commands) is each line is equivalent to
an input line in ghci. Note that the last line binds a variable from an
action in the top level IO monad, something not possible in a module.
2) It would be nice to have multiline inputs if the parser can tell that the
input is incomplete rather than malformed. One case is an empty 'do'
construct:
\begin{interaction}
Prelude> :load Sine
Sine> :show bindings
ts :: Data.Vector.Storable Double
ss :: Data.Vector.Storable Double
figure :: Graphics.Rendering.Plot.Figure.Figure ()
Sine> withFigureMVar figure1 $ do
Figure a > withTitle $ do
Text a > setText "15 Hz
sine wave"
Text a > setFontSize 16
Text a >
Figure a >
Sine>
\end{interaction}
(an empty line ends the 'do' construct and returns to next higher level).
Is this a feasible addition to GHCi? This way the full power of GHCi is
accessible to an interactive mathematics session rather than developing a
custom interface on top of the GHC API.
Vivian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20100913/8257ccb6/attachment.html
More information about the Glasgow-haskell-users
mailing list