greet
examples/greet.omg
examples/greet.omg19 lines
1{- Ask for a name and greet its owner.
2
3 omegyu run examples/greet.omg
4
5 A `do` block without a dictionary is in the builtin `IO` monad; each
6 `x <- action` names the result of an action for the statements after it.
7-}
8
9let Console = std:IO
10
11let greeting : Text -> Text = \name -> "Hello, ${name}!"
12
13in do {
14 Console.putStr "What is your name? ";
15 answer <- Console.getLine;
16 -- At the end of the input there is no answer.
17 let name = std:Optional.default "stranger" answer;
18 Console.putStrLn (greeting name)
19 }