on 9939708 help sign in
hakyll/src/Hakyll/Core/Target.hs
32 lines 861 B history raw
1-- | A target represents one compilation unit, e.g. a blog post, a CSS file...
2--
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4module Hakyll.Core.Target
5 ( DependencyLookup
6 , TargetM
7 , Target
8 , runTarget
9 , getIdentifier
10 , getResourceString
11 ) where
13import Control.Applicative ((<$>))
14import Control.Monad.Reader (ask)
15import Control.Monad.Trans (liftIO)
17import Hakyll.Core.Identifier
18import Hakyll.Core.Target.Internal
19import Hakyll.Core.ResourceProvider
21-- | Get the current identifier
22--
23getIdentifier :: TargetM a Identifier
24getIdentifier = TargetM $ targetIdentifier <$> ask
26-- | Get the resource content as a string
27--
28getResourceString :: TargetM a String
29getResourceString = TargetM $ do
30 provider <- targetResourceProvider <$> ask
31 identifier <- unTargetM getIdentifier
32 liftIO $ resourceString provider identifier