From 481a10883a504949f9121712f299200295688ad1 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Wed, 10 Mar 2021 19:24:37 +1300 Subject: [PATCH] Drop outdated dependencies. --- rhapsode.cabal | 3 +-- src/Input.hs | 8 +++----- src/Links.hs | 10 ++++------ src/Render.hs | 6 +++--- src/Types.hs | 16 ++++++++-------- 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/rhapsode.cabal b/rhapsode.cabal index 4d678fc..cb7aa10 100644 --- a/rhapsode.cabal +++ b/rhapsode.cabal @@ -65,8 +65,7 @@ library network-uri, stylist >= 2.4 && <3, css-syntax, xml-conduit-stylist >= 2.3 && <3, scientific, async, hurl >= 2, filepath, temporary, - file-embed >= 0.0.9 && < 0.1, time, - text-trie >= 0.2.5, parallel >= 1, strict >= 0.4 + file-embed >= 0.0.9 && < 0.1, time, parallel >= 1 -- Directories containing source files. hs-source-dirs: src diff --git a/src/Input.hs b/src/Input.hs index 1c7823a..41df073 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -15,6 +15,7 @@ import Network.URI import Network.URI.Fetch import Network.URI.Charset import qualified Data.Map as M +import qualified Data.Set as Set import Data.List (intercalate) import Data.Time.Clock @@ -30,9 +31,6 @@ import System.Directory import System.FilePath (()) import Data.FileEmbed --- For history -import qualified Data.Trie.Text as Trie - -- For C API import Types import Data.HTML2CSS (html2css) @@ -136,7 +134,7 @@ pageForDoc uri doc = do return Page {Types.url = uri, html = doc, css = styles, -- These fields are all blank, to be filled in later by logHistory & parseDocument' pageTitle = "", pageMIME = "", apps = [], - backStack = [], forwardStack = [], visitedURLs = Trie.empty} + backStack = [], forwardStack = [], visitedURLs = Set.empty} logHistory hist ret@Page {Types.url = url', html = doc} = do dir <- getXdgDirectory XdgData "rhapsode" @@ -147,7 +145,7 @@ logHistory hist ret@Page {Types.url = url', html = doc} = do "=>", uriToStr' url', show now, title ] - return ret { pageTitle = title, visitedURLs = Trie.insert (Txt.pack $ uriToStr' url') () hist} + return ret { pageTitle = title, visitedURLs = Set.insert (Txt.pack $ uriToStr' url') hist} where getTitle (XML.Element "title" _ childs) = Txt.concat [txt | XML.NodeContent txt <- childs] getTitle (XML.Element "h1" _ childs) = Txt.concat [txt | XML.NodeContent txt <- childs] diff --git a/src/Links.hs b/src/Links.hs index aa38638..ecf7283 100644 --- a/src/Links.hs +++ b/src/Links.hs @@ -22,11 +22,9 @@ import System.FilePath import System.IO (hPrint, stderr) -- For error reporting -- For suggestions.gmni -import Data.Trie.Text (Trie) -import qualified Data.Trie.Text as Trie +import qualified Data.Set as Set import Data.List (nub, intercalate) import Control.Concurrent (forkIO) -import qualified System.IO.Strict as Strict data Link = Link { label :: Text, @@ -168,11 +166,11 @@ updateSuggestions page = do let path = dir "suggestions.gmni" exists <- doesFileExist path suggestions <- if not exists then return [] else do - file <- Strict.readFile path - return [line' | line <- lines file, line'@(_:uri':_) <- [words line], not (pack uri' `Trie.member` visitedURLs page)] + file <- Prelude.readFile path + return [line' | line <- lines file, line'@(_:uri':_) <- [words line], not (pack uri' `Set.member` visitedURLs page)] let suggestions' = suggestions ++ nub [["=>", uri', domain] | link <- links, - let uri' = uriToString id (href link) "", not (pack uri' `Trie.member` visitedURLs page)] + let uri' = uriToString id (href link) "", not (pack uri' `Set.member` visitedURLs page)] createDirectoryIfMissing True dir Prelude.writeFile path $ unlines $ map unwords suggestions' diff --git a/src/Render.hs b/src/Render.hs index 1fcea65..01b0100 100644 --- a/src/Render.hs +++ b/src/Render.hs @@ -36,7 +36,7 @@ import System.IO.Temp import Control.Exception (catch) --- For psuedoclasses -import qualified Data.Trie.Text as Trie +import qualified Data.Set as Set import qualified Data.CSS.Syntax.Selector as CSSSel -- Internal Rhapsode Subcomponents @@ -124,8 +124,8 @@ targetSel ('#':'.':anchor) = targetSel ('#':id) = [CSSTok.Hash CSSTok.HUnrestricted $ Txt.pack id] targetSel _ = [] -testVisited :: Trie.Trie () -> URI -> String -> Bool -testVisited hist base val = uriToText url `Trie.member` hist +testVisited :: Set.Set Text -> URI -> String -> Bool +testVisited hist base val = uriToText url `Set.member` hist where url = fromMaybe nullURI (parseURIReference val) `relativeTo` base uriToText uri = pack $ uriToString id uri "" diff --git a/src/Types.hs b/src/Types.hs index 1f82b43..ccb367f 100644 --- a/src/Types.hs +++ b/src/Types.hs @@ -11,13 +11,13 @@ import Network.URI import Network.URI.Fetch (Application(..)) -- For the in-memory history log -import Data.Trie.Text (Trie) +import qualified Data.Set as Set +import Data.Set (Set) +import Data.Text (Text(..)) import qualified Data.Text as Txt -import qualified Data.Trie.Text as Trie import System.Directory import System.FilePath (()) import Control.Parallel (par) -import qualified System.IO.Strict as Strict import Foreign.Ptr import Foreign.StablePtr @@ -34,22 +34,22 @@ data Page = Page { backStack :: [(String, URI)], forwardStack :: [(String, URI)], -- Probably don't need an MVar here, but let's be safe! - visitedURLs :: Trie () + visitedURLs :: Set Text } foreign export ccall c_initialReferer :: IO (StablePtr Page) -loadVisited :: IO (Trie ()) +loadVisited :: IO (Set Text) loadVisited = do dir <- getXdgDirectory XdgData "rhapsode" let path = dir "history.gmni" exists <- doesFileExist path if exists then do - file <- Strict.readFile path -- Can't leave this file locked when I'll shortly append to it! - let hist = Trie.fromList [(Txt.pack uri, ()) | _:uri:_ <- map words $ lines file] + file <- Prelude.readFile path -- Can't leave this file locked when I'll shortly append to it! + let hist = length file `seq` Set.fromList [Txt.pack uri | _:uri:_ <- map words $ lines file] hist `par` return hist - else return Trie.empty + else return Set.empty c_initialReferer = do cwd <- getCurrentDirectory -- 2.30.2