let readPassword () = let rec readMask pw = let k = System.Console.ReadKey() match k.Key with | System.ConsoleKey.Enter -> pw | System.ConsoleKey.Escape -> pw | System.ConsoleKey.Backspace -> match pw with | [] -> readMask [] | _::t -> System.Console.Write " \b" readMask t | _ -> System.Console.Write "\b*" readMask (k.KeyChar::pw) let password = readMask [] |> Seq.rev |> System.String.Concat System.Console.WriteLine () password