Debian Codegraph @

tests/system/io/Main.agda

raw
1 {-# OPTIONS --guardedness #-}
2
3 module Main where
4
5 open import Data.String.Base
6 open import Function.Base using (_$_; case_of_)
7 open import IO
8 open import System.Exit using (exitSuccess)
9
10 main : Main
11 main = run $ do
12 -- Ensure no buffering so that the prompt "echo< "
13 -- gets outputed immediately
14 hSetBuffering stdout noBuffering
15 forever $ do
16 putStr "echo< "
17 -- Get a line from the user and immediately inspect it
18 -- If it's a magic "exit" keyword then we exit, otherwise
19 -- we print the echo'd message and let the `forever` action
20 -- continue
21 str ← getLine
22 case str of λ where
23 "exit" → exitSuccess
24 _ → putStrLn ("echo> " ++ str)