Verified Commit 4a0059b6 authored by Camil Staps's avatar Camil Staps 🚀

Suggestions now have type Request

parent aec79fea
......@@ -39,7 +39,7 @@ import Levenshtein
, data :: [Result]
, msg :: String
, more_available :: Maybe Int
, suggestions :: Maybe [(String, Int)]
, suggestions :: Maybe [(Request, Int)]
}
:: Result = FunctionResult FunctionResult
......@@ -167,12 +167,12 @@ where
}
, w)
suggs :: !(Maybe String) !Type !TypeDB -> Maybe [(String, Int)]
suggs :: !(Maybe String) !Type !TypeDB -> Maybe [(Request, Int)]
suggs n (Func is r cc) db
| length is < 3
= Just [let t` = concat $ print False $ Func is` r cc in
let s = if (isJust n) (fromJust n + " ") "" + ":: " + t` in
(s, length $ search {zero & name=n, unify=Just t`} db)
let request = {zero & name=n, unify=Just t`} in
(request, length $ search request db)
\\ is` <- permutations is | is` <> is]
suggs _ _ _ = Nothing
......
......@@ -111,7 +111,8 @@ fields:
- `suggestions`
If there are similar searches that may return more results, this will be an
array of two-tuples with the alternative search and the number of results.
array of two-tuples with the alternative search (which has the same fields as
a request) and the number of results.
### Talking with the Clean backend directly
`CloogleServer` is a TCP server listening on port 31215 (typically). Send a
......
......@@ -137,8 +137,16 @@ function getResults(str, page) {
var str = '<hr/><div id="suggestions"><b>Did you mean...</b><table>';
for (i in suggs) {
var sug = suggs[i][0];
str += '<tr><td><a class="hidden" href="#' + encodeURIComponent(sug) + '"><code>' +
highlightFunction(sug) + '</code></a></td><td>' +
var sugstr = []
if ('name' in sug) {
sugstr.push(sug.name);
}
if ('unify' in sug) {
sugstr.push(':: ' + sug.unify);
}
sugstr = sugstr.join(' ');
str += '<tr><td><a class="hidden" href="#' + encodeURIComponent(sugstr) + '"><code>' +
highlightFunction(sugstr) + '</code></a></td><td>' +
suggs[i][1] + ' results</td></tr>';
}
str += '</table></div>';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment