@@ -34,6 +34,7 @@ import Data.Monoid (Endo (Endo), appEndo)
3434import Data.Proxy
3535import qualified Data.Set as Set
3636import qualified Data.Text as T
37+ import Data.Text (Text )
3738import Data.Time (UTCTime )
3839import Data.Time (getCurrentTime )
3940import Data.Time.Clock.POSIX (POSIXTime , posixSecondsToUTCTime ,
@@ -691,7 +692,7 @@ mkButton s alt' = do
691692mkWorkerStat :: (Vector WorkerRow ) -> (PkgN -> PkgIdxTs -> Int )
692693mkWorkerStat ws = \ x1 x2 -> Map. findWithDefault 0 (x1,x2) (Map. fromListWith (+) [ ((pn,is),1 ) | WorkerRow { wrPkgname = Just pn, wrIdxState = Just is } <- V. toList ws ])
693694
694- tshow :: Show a => a -> T. Text
695+ tshow :: Show a => a -> Text
695696tshow = T. pack . show
696697
697698data LR = L | R | LR
@@ -737,7 +738,7 @@ pkgTagList m = Map.fromListWith (List.++) $ do
737738joinE :: forall t m a . (Reflex t , MonadHold t m ) => Event t (Event t a ) -> m (Event t a )
738739joinE = fmap switch . hold never
739740
740- clickElement_ :: forall t m . (DomBuilder t m , PostBuild t m ) => T. Text -> T. Text -> m (Event t () )
741+ clickElement_ :: forall t m . (DomBuilder t m , PostBuild t m ) => Text -> Text -> m (Event t () )
741742clickElement_ elm t = do
742743 let cfg = (def :: ElementConfig EventResult t (DomBuilderSpace m ))
743744 & elementConfig_eventSpec %~ addEventSpecFlags (Proxy :: Proxy (DomBuilderSpace m )) Click (\ _ -> preventDefault)
@@ -750,38 +751,36 @@ stripSearch sJ
750751 | Just sJ' <- JSS. stripSuffix " $" sJ = sJ'
751752 | otherwise = sJ
752753
753- splitInfixPkg :: JSS. JSString -> JSS. JSString -> (T. Text , T. Text , T. Text )
754+ splitInfixPkg :: JSS. JSString -> JSS. JSString -> (Text , Text , Text )
754755splitInfixPkg stripSJ pkg = (frontT, midT, backT)
755756 where
756757 textS = JSS. textFromJSString stripSJ
757758 (frontT, reminderT) = T. breakOn textS (JSS. textFromJSString pkg)
758759 (midT, backT) = T. breakOnEnd textS reminderT
759760
760- calcMatch :: JSS. JSString -> JSS. JSString -> (Map. Map T. Text () , Map. Map T. Text (T. Text ,T. Text ,T. Text ))
761- calcMatch sJss pkg =
762- let stripSJ = stripSearch sJss
763- in
764- case stripSJ == pkg of
765- True -> (Map. singleton (JSS. textFromJSString pkg) () , Map. empty)
766- False -> filterPkgSearch stripSJ pkg
761+ calcMatch :: JSS. JSString -> JSS. JSString -> (Map. Map Text () , Map. Map Text (Text ,Text ,Text ))
762+ calcMatch sJss pkg
763+ | stripSJ == pkg = (Map. singleton (JSS. textFromJSString pkg) () , Map. empty)
764+ | otherwise = filterPkgSearch stripSJ pkg
765+ where
766+ stripSJ = stripSearch sJss
767767
768- filterPkgSearch :: JSS. JSString -> JSS. JSString -> (Map. Map T. Text () , Map. Map T. Text (T. Text ,T. Text ,T. Text ))
768+ filterPkgSearch :: JSS. JSString -> JSS. JSString -> (Map. Map Text () , Map. Map Text (Text ,Text ,Text ))
769769filterPkgSearch sJss pkg
770770 | Just sJ' <- JSS. stripPrefix " ^" sJss = if JSS. isPrefixOf sJ' pkg
771771 then (Map. empty, Map. singleton (JSS. textFromJSString pkg) (splitInfixPkg sJ' pkg))
772- else ( Map. empty, Map. empty)
772+ else mempty
773773 | Just sJ' <- JSS. stripSuffix " $" sJss = if JSS. isSuffixOf sJ' pkg
774774 then (Map. empty, Map. singleton (JSS. textFromJSString pkg) (splitInfixPkg sJ' pkg))
775- else ( Map. empty, Map. empty)
775+ else mempty
776776 | otherwise = if JSS. isInfixOf sJss pkg
777777 then (Map. empty, Map. singleton (JSS. textFromJSString pkg) (splitInfixPkg sJss pkg))
778- else ( Map. empty, Map. empty)
778+ else mempty
779779
780780calcMatches :: [JSS. JSString ] -> JSS. JSString -> Matches
781- calcMatches pkgs sJss =
782- if JSS. length sJss < 3
783- then matchesEmpty
784- else Matches { matchesInput = textS, matchesExact = exactMap, matchesInfix = othersMap}
781+ calcMatches pkgs sJss
782+ | JSS. length sJss < 3 = matchesEmpty
783+ | otherwise = Matches { matchesInput = textS, matchesExact = exactMap, matchesInfix = othersMap}
785784 where
786785 textS = JSS. textFromJSString sJss
787786 (exactMap,othersMap) = F. foldMap (calcMatch sJss) pkgs
@@ -804,7 +803,7 @@ searchBoxWidget dynPkgs0 = mdo
804803
805804searchResultWidget :: forall t m . (MonadFix m , MonadHold t m , PostBuild t m , DomBuilder t m )
806805 => Dynamic t Matches
807- -> m (Event t T. Text )
806+ -> m (Event t Text )
808807searchResultWidget mDyn =
809808 el " ul" $ do
810809 exactE <- listViewWithKey (matchesExact <$> mDyn) $ \ eId _ -> do
0 commit comments