hakyll/src/Hakyll/Core/Metadata.hs

33 lines
1.1 KiB
Haskell
Raw Normal View History

2012-11-09 15:34:45 +00:00
--------------------------------------------------------------------------------
module Hakyll.Core.Metadata
( Metadata
2012-11-22 12:38:28 +00:00
, MonadMetadata (..)
2012-11-09 15:34:45 +00:00
) where
--------------------------------------------------------------------------------
2012-11-22 12:38:28 +00:00
import Control.Monad (forM)
2012-11-13 22:59:49 +00:00
import Data.Map (Map)
2012-11-09 15:34:45 +00:00
2012-11-22 12:38:28 +00:00
--------------------------------------------------------------------------------
import Hakyll.Core.Identifier
import Hakyll.Core.Identifier.Pattern
2012-11-09 15:34:45 +00:00
--------------------------------------------------------------------------------
type Metadata = Map String String
2012-11-22 12:38:28 +00:00
--------------------------------------------------------------------------------
class Monad m => MonadMetadata m where
getMetadata :: Identifier -> m Metadata
getMatches :: Pattern -> m [Identifier]
getAllMetadata :: Pattern -> m [(Identifier, Metadata)]
getAllMetadata pattern = do
matches' <- getMatches pattern
forM matches' $ \id' -> do
metadata <- getMetadata id'
return (id', metadata)