From 8b5347eb26c28bc3d4b80230df488c8ae959c47c Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Mon, 4 Apr 2011 21:57:28 +0200 Subject: Assoc. list-based implementation of tags Goal is to be able to sort them later (see gh-22) --- src/Hakyll/Web/Tags.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Hakyll/Web/Tags.hs b/src/Hakyll/Web/Tags.hs index c971b0f..32076a0 100644 --- a/src/Hakyll/Web/Tags.hs +++ b/src/Hakyll/Web/Tags.hs @@ -40,7 +40,6 @@ module Hakyll.Web.Tags import Prelude hiding (id) import Control.Category (id) import Control.Applicative ((<$>)) -import Data.Map (Map) import qualified Data.Map as M import Data.List (intersperse, intercalate) import Control.Arrow (arr, (&&&), (>>>), (***), (<<^), returnA) @@ -65,7 +64,7 @@ import Hakyll.Core.Util.String -- | Data about tags -- data Tags a = Tags - { tagsMap :: Map String [Page a] + { tagsMap :: [(String, [Page a])] } deriving (Show, Typeable) instance Binary a => Binary (Tags a) where @@ -91,7 +90,8 @@ readTagsWith :: (Page a -> [String]) -- ^ Function extracting tags from a page -> [Page a] -- ^ Pages -> Tags a -- ^ Resulting tags readTagsWith f pages = Tags - { tagsMap = foldl (M.unionWith (++)) M.empty (map readTagsWith' pages) + { tagsMap = M.toList $ + foldl (M.unionWith (++)) M.empty (map readTagsWith' pages) } where -- Create a tag map for one page @@ -122,7 +122,7 @@ renderTags :: (String -> Identifier) renderTags makeUrl makeItem concatItems = proc (Tags tags) -> do -- In tags' we create a list: [((tag, route), count)] tags' <- mapCompiler ((id &&& (getRouteFor <<^ makeUrl)) *** arr length) - -< M.toList tags + -< tags let -- Absolute frequencies of the pages freqs = map snd tags' -- cgit v1.2.3