[commit: packages/haskeline] haskeline-0.7: Add fallbackCompletion to support module completion in ghci :add (#91) (85cbdff)

git at git.haskell.org git at git.haskell.org
Thu Jan 17 12:17:15 UTC 2019


Repository : ssh://git@git.haskell.org/haskeline

On branch  : haskeline-0.7
Link       : http://git.haskell.org/packages/haskeline.git/commitdiff/85cbdff43efb645956ac64aefd06839e56c367b4

>---------------------------------------------------------------

commit 85cbdff43efb645956ac64aefd06839e56c367b4
Author: Ken Micklas <kmicklas at gmail.com>
Date:   Sat Oct 20 12:23:08 2018 -0400

    Add fallbackCompletion to support module completion in ghci :add (#91)


>---------------------------------------------------------------

85cbdff43efb645956ac64aefd06839e56c367b4
 System/Console/Haskeline/Completion.hs | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/System/Console/Haskeline/Completion.hs b/System/Console/Haskeline/Completion.hs
index b17bb0c..04b8e9a 100644
--- a/System/Console/Haskeline/Completion.hs
+++ b/System/Console/Haskeline/Completion.hs
@@ -3,6 +3,7 @@ module System.Console.Haskeline.Completion(
                             Completion(..),
                             noCompletion,
                             simpleCompletion,
+                            fallbackCompletion,
                             -- * Word completion
                             completeWord,
                             completeWordWithPrev,
@@ -188,3 +189,12 @@ fixPath ('~':c:path) | isPathSeparator c = do
     home <- getHomeDirectory
     return (home </> path)
 fixPath path = return path
+
+-- | If the first completer produces no suggestions, fallback to the second
+-- completer's output.
+fallbackCompletion :: Monad m => CompletionFunc m -> CompletionFunc m -> CompletionFunc m
+fallbackCompletion a b input = do
+    aCompletions <- a input
+    if null (snd aCompletions)
+        then b input
+        else return aCompletions



More information about the ghc-commits mailing list