Commit bf937f1a authored by Vaibhav Sagar's avatar Vaibhav Sagar

IHaskell.Eval.Hoogle: fix issue with parsing multiple `::`

parent a6d0a651
...@@ -25,7 +25,7 @@ import Data.Vector (toList) ...@@ -25,7 +25,7 @@ import Data.Vector (toList)
import Network.HTTP.Client import Network.HTTP.Client
import Network.HTTP.Client.TLS import Network.HTTP.Client.TLS
import StringUtils (replace, split, strip) import StringUtils (replace, split, splitFirst, strip)
-- | Types of formats to render output to. -- | Types of formats to render output to.
data OutputFormat = Plain -- ^ Render to plain text. data OutputFormat = Plain -- ^ Render to plain text.
...@@ -193,7 +193,7 @@ renderSelf string loc ...@@ -193,7 +193,7 @@ renderSelf string loc
packageSub package packageSub package
| otherwise = | otherwise =
let [name, args] = split "::" string let [name, args] = splitFirst "::" string
package = extractPackageName loc package = extractPackageName loc
modname = extractModuleName loc modname = extractModuleName loc
in span "hoogle-name" in span "hoogle-name"
......
...@@ -5,11 +5,13 @@ module StringUtils ( ...@@ -5,11 +5,13 @@ module StringUtils (
rstrip, rstrip,
replace, replace,
split, split,
splitFirst,
) where ) where
import IHaskellPrelude import IHaskellPrelude
import qualified Data.Text as T import qualified Data.Text as T
import Data.List.Split (splitOn) import Data.List.Split (splitOn)
import qualified Data.List.Split as Split
lstrip :: String -> String lstrip :: String -> String
lstrip = dropWhile (`elem` (" \t\r\n" :: String)) lstrip = dropWhile (`elem` (" \t\r\n" :: String))
...@@ -26,3 +28,8 @@ replace needle replacement haystack = ...@@ -26,3 +28,8 @@ replace needle replacement haystack =
split :: String -> String -> [String] split :: String -> String -> [String]
split = splitOn split = splitOn
splitFirst :: String -> String -> [String]
splitFirst delim str = let
(head:_:tail) = Split.split (Split.onSublist delim) str
in [head, concat tail]
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