Skip to content

Instantly share code, notes, and snippets.

@stdray
Created August 21, 2015 13:54
Show Gist options
  • Select an option

  • Save stdray/29258310b4028c20b227 to your computer and use it in GitHub Desktop.

Select an option

Save stdray/29258310b4028c20b227 to your computer and use it in GitHub Desktop.
open System
type Command =
| DoSomeStuff
| DoSomeOtherStuff
let tryParse str =
DoSomeStuff |> Some
let execute cmd =
printfn "%A" cmd
let rec readLines stopCond = seq {
let line = Console.ReadLine()
if not (stopCond line) then
yield line
yield! readLines stopCond
}
[<EntryPoint>]
let main argv =
let lines = readLines (fun str -> String.IsNullOrEmpty(str) || str = "QQ")
for line in lines do
match tryParse line with
| None -> printfn "Can not parse command"
| Some(cmd) -> execute cmd
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment