1{-# OPTIONS_GHC -Wall #-}
2module Reporting.Error.Helpers where
4import Data.Function (on)
5import qualified Data.List as List
6import qualified Text.EditDistance as Dist
13nearbyNames :: (a -> String) -> a -> [a] -> [a]
14nearbyNames format name names =
16 if length (format name) < 3 then 1 else 2
19 |> map (\x -> (distance (format name) (format x), x))
20 |> List.sortBy (compare `on` fst)
21 |> filter ( (<= editDistance) . abs . fst )
25distance :: String -> String -> Int
27 Dist.restrictedDamerauLevenshteinDistance Dist.defaultEditCosts x y
30maybeYouWant :: [String] -> String
31maybeYouWant suggestions =
37 "Maybe you want one of the following?\n"
38 ++ concatMap ("\n "++) (take 4 suggestions)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list