Idris2/samples/FFI-readline/Test/ReadTab.idr
Edwin Brady 4f10bfcfd2 Copy samples directory from Idris2-boot
This is referred to in the documentation, so should be there
2020-06-30 10:51:09 +01:00

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