I`m trying to make some code to keep asking the user until a valid file path or "exit" is input.
What I have now:
let (|ValidPath|_|) str =
if File.Exists str then Some ValidPath
else None
type Return =
|Path of string
|Exit
let rec ask =
printfn "%s" "Please enter a valid path or \"exit\""
let input = Console.ReadLine()
match input with
| "exit" -> Exit
| ValidPath -> Path input
| _ -> ask
The ask
function has a The value 'aks' will be evaluated as part of its own definition
error.
What can I do?