mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-22 03:01:31 +03:00
20 lines
494 B
Idris
20 lines
494 B
Idris
|
import Text.Readline
|
||
|
|
||
|
testComplete : String -> Int -> IO (Maybe String)
|
||
|
testComplete text 0 = pure $ Just "hamster"
|
||
|
testComplete text 1 = pure $ Just "bar"
|
||
|
testComplete text st = pure Nothing
|
||
|
|
||
|
loop : IO ()
|
||
|
loop = do Just x <- readline "> "
|
||
|
| Nothing => putStrLn "EOF"
|
||
|
putStrLn x
|
||
|
when (x /= "") $ addHistory x
|
||
|
if x /= "quit"
|
||
|
then loop
|
||
|
else putStrLn "Done"
|
||
|
|
||
|
main : IO ()
|
||
|
main = do setCompletionFn testComplete
|
||
|
loop
|