git.iko.soy/rowtype-yoga/purescript-docs-search
on master help sign in
Remove unnecessary FFI
557bb71klntsky
src/Docs/Search/Interactive.jsdeleted−5
@@ -1,5 +0,0 @@
1−/* global exports */
2−
3−exports.consoleClear = function () {
4− console.clear();
5−};
src/Docs/Search/Interactive.purs+9−12
@@ -29,7 +29,7 @@ import Docs.Search.TypePrinter (keyword, showConstraint, showFunDeps, showKind,
29import Effect (Effect)
29import Effect (Effect)
30import Effect.Aff (launchAff_)
30import Effect.Aff (launchAff_)
31import Effect.Class (liftEffect)
31import Effect.Class (liftEffect)
32−import Effect.Console (log)
32+import Effect.Console (log, clear) as Console
33import Node.ReadLine (createConsoleInterface, question)
33import Node.ReadLine (createConsoleInterface, question)
34
34
35
35
@@ -43,7 +43,7 @@ run :: Config -> Effect Unit
43run cfg = launchAff_ $ do
43run cfg = launchAff_ $ do
44
44
45 liftEffect do
45 liftEffect do
46− log "Loading search index..."
46+ Console.log "Loading search index..."
47
47
48 docsJsons <- IndexBuilder.decodeDocsJsons cfg
48 docsJsons <- IndexBuilder.decodeDocsJsons cfg
49 packageMetas <- IndexBuilder.decodeBowerJsons cfg
49 packageMetas <- IndexBuilder.decodeBowerJsons cfg
@@ -60,7 +60,7 @@ run cfg = launchAff_ $ do
60 countOfPackages = Array.length packageMetas
60 countOfPackages = Array.length packageMetas
61
61
62 liftEffect do
62 liftEffect do
63− log $
63+ Console.log $
64 "Loaded " <>
64 "Loaded " <>
65 show countOfDefinitions <>
65 show countOfDefinitions <>
66 " definitions and " <>
66 " definitions and " <>
@@ -81,15 +81,15 @@ run cfg = launchAff_ $ do
81
81
82 let total = Array.length results
82 let total = Array.length results
83
83
84− consoleClear
84+ Console.clear
85
85
86+ Console.log $
86− if total > 0 then do
87+ if total > 0 then do
87− log $
88 Array.intercalate "\n\n\n" $
88 Array.intercalate "\n\n\n" $
89− showResult <$> Array.reverse results
89+ showResult <$> Array.reverse results
90− else do
90+ else
91− log $
92 "Your search for " <> bold input <> " did not yield any results."
91 "Your search for " <> bold input <> " did not yield any results."
92+
93 call inputHandler interface
93 call inputHandler interface
94
94
95 interface <- createConsoleInterface (mkCompleter index)
95 interface <- createConsoleInterface (mkCompleter index)
@@ -296,6 +296,3 @@ leftPad w str = Array.fold (Array.replicate w " ") <> str
296
296
297rightPad :: Int -> String -> String
297rightPad :: Int -> String -> String
298rightPad w str = str <> Array.fold (Array.replicate (w - String.length str) " ")
298rightPad w str = str <> Array.fold (Array.replicate (w - String.length str) " ")
299−
300−
301−foreign import consoleClear :: Effect Unit