forked from judah/haskeline
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I am not author of the patch, this commit use patch from https://paste.debian.net/plainh/ec5ae9040 see judah#84 judah#84 (comment)
- Loading branch information
Showing
4 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module Main where | ||
|
||
import System.Console.Haskeline | ||
import System.Console.Haskeline.Completion | ||
import System.Environment | ||
import Control.Exception (AsyncException(..)) | ||
|
||
{- | ||
Testing case-insensitive autocompletion. | ||
Usage: | ||
(from the project folder) | ||
cabal new-repl | ||
(an then from inside ghci) | ||
:load examples/Case.hs | ||
main | ||
-} | ||
|
||
{- Expected behaviour: | ||
r<tab> does not change cap of the letter | ||
R<tab> does not change cap of the letter | ||
Ca<tab> suggestions are "Cane callo" | ||
ca<tab> suggestions are "callo Cane" | ||
ma<tab> gets completed to "maybe" | ||
Ma<tab> gets completed to "Maybe" | ||
cane<tab> gets completed to "Cane" | ||
-} | ||
|
||
mySettings :: Settings IO | ||
mySettings = setComplete cfCI defaultSettings | ||
where | ||
cfCI :: CompletionFunc IO | ||
cfCI = completeList Nothing " " | ||
["Rana", "rosa", "Cane", "callo", "maybe", "Maybe"] | ||
IgnoreCase | ||
|
||
main :: IO () | ||
main = runInputT mySettings $ withInterrupt $ loop getInputLine 0 | ||
where | ||
loop inputFunc n = do | ||
minput <- handle (\Interrupt -> return (Just "Caught interrupted")) | ||
$ inputFunc (show n ++ ":") | ||
case minput of | ||
Nothing -> return () | ||
Just "quit" -> return () | ||
Just "q" -> return () | ||
Just s -> do | ||
outputStrLn ("line " ++ show n ++ ":" ++ s) | ||
loop inputFunc (n+1) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters