module Hoogle.Search.Result where
import General.Code
import Data.TagStr
import Hoogle.DataBase.All
import Hoogle.Item.All
import Data.Binary.Defer.Index
data Result = Result
{resultEntry :: Link Entry
,resultView :: [EntryView]
,resultScore :: [Score]
}
deriving Show
data Score = TypeScore TypeScore
| TextScore TextScore
deriving (Eq,Ord)
instance Show Score where
showList xs = showString $ concat $ intersperse " & " $ map show xs
show (TypeScore x) = show x
show (TextScore x) = show x
renderResult :: Result -> (Maybe [String], TagStr, String)
renderResult r = (if entryType e == EntryModule then Nothing
else liftM (moduleName . fromLink) $ entryModule e
,renderEntryText (resultView r) $ entryText e
,show $ resultScore r)
where e = fromLink $ resultEntry r