Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.23 KB | None | 0 0
  1. open System.Diagnostics
  2.  
  3. let fsiProcess =
  4.     let filename,args = if System.Environment.OSVersion.Platform = System.PlatformID.Unix
  5.                         then
  6.                             "/opt/mono-2.10/bin/mono", "/usr/lib/fsharp/fsi.exe"   // does not work
  7.                             // "fsharpi", "" // does not work
  8.                             // "/usr/bin/mono", "/usr/lib/fsharp/fsi.exe" // does not work
  9.                         else
  10.                             @"C:\Program Files (x86)\Microsoft F#\v4.0\fsi.exe", ""
  11.     let startInfo =
  12.       new ProcessStartInfo
  13.         (FileName = filename, UseShellExecute = false, Arguments = args,
  14.          RedirectStandardError = true, CreateNoWindow = true, RedirectStandardOutput = true,
  15.          RedirectStandardInput = true)
  16.     try
  17.       let p = Process.Start(startInfo)
  18.       do p.EnableRaisingEvents <- true
  19.       do p.BeginOutputReadLine ()
  20.       p
  21.     with e ->
  22.       printfn "bah"
  23.       reraise()
  24.  
  25. fsiProcess.OutputDataReceived.Add(fun x ->
  26.                                     let s = x.Data
  27.                                     printfn "received %s:" s)
  28.  
  29. fsiProcess.StandardInput.WriteLine ("let foo = 1;;\n")
  30.  
  31. System.Console.ReadKey () |> ignore
  32.  
  33. fsiProcess.Kill ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement