    --------------------------------------------------------------------------------
    -- | An item is a combination of some content and its 'Identifier'. This way, we
    -- can still use the 'Identifier' to access metadata.
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DeriveTraversable  #-}
    module Hakyll.Core.Item
        ( Item (..)
        , itemSetBody
        , withItemBody
        ) where

    --------------------------------------------------------------------------------
    import           Data.Binary                   (Binary (..))
    import           Data.Typeable                 (Typeable)
    import           Prelude                       hiding (foldr)

    --------------------------------------------------------------------------------
    import           Hakyll.Core.Compiler.Internal
    import           Hakyll.Core.Identifier

    --------------------------------------------------------------------------------
    data Item a = Item
        { forall a. Item a -> Identifier
    itemIdentifier :: Identifier
        , forall a. Item a -> a
    itemBody       :: a
        } deriving (Int -> Item a -> ShowS
    [Item a] -> ShowS
    Item a -> String
    (Int -> Item a -> ShowS)
    -> (Item a -> String) -> ([Item a] -> ShowS) -> Show (Item a)
    forall a. Show a => Int -> Item a -> ShowS
    forall a. Show a => [Item a] -> ShowS
    forall a. Show a => Item a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: forall a. Show a => Int -> Item a -> ShowS
    showsPrec :: Int -> Item a -> ShowS
    $cshow :: forall a. Show a => Item a -> String
    show :: Item a -> String
    $cshowList :: forall a. Show a => [Item a] -> ShowS
    showList :: [Item a] -> ShowS
    Show, Typeable, (forall a b. (a -> b) -> Item a -> Item b)
    -> (forall a b. a -> Item b -> Item a) -> Functor Item
    forall a b. a -> Item b -> Item a
    forall a b. (a -> b) -> Item a -> Item b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> Item a -> Item b
    fmap :: forall a b. (a -> b) -> Item a -> Item b
    $c<$ :: forall a b. a -> Item b -> Item a
    <$ :: forall a b. a -> Item b -> Item a
    Functor, (forall m. Monoid m => Item m -> m)
    -> (forall m a. Monoid m => (a -> m) -> Item a -> m)
    -> (forall m a. Monoid m => (a -> m) -> Item a -> m)
    -> (forall a b. (a -> b -> b) -> b -> Item a -> b)
    -> (forall a b. (a -> b -> b) -> b -> Item a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Item a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Item a -> b)
    -> (forall a. (a -> a -> a) -> Item a -> a)
    -> (forall a. (a -> a -> a) -> Item a -> a)
    -> (forall a. Item a -> [a])
    -> (forall a. Item a -> Bool)
    -> (forall a. Item a -> Int)
    -> (forall a. Eq a => a -> Item a -> Bool)
    -> (forall a. Ord a => Item a -> a)
    -> (forall a. Ord a => Item a -> a)
    -> (forall a. Num a => Item a -> a)
    -> (forall a. Num a => Item a -> a)
    -> Foldable Item
    forall a. Eq a => a -> Item a -> Bool
    forall a. Num a => Item a -> a
    forall a. Ord a => Item a -> a
    forall m. Monoid m => Item m -> m
    forall a. Item a -> Bool
    forall a. Item a -> Int
    forall a. Item a -> [a]
    forall a. (a -> a -> a) -> Item a -> a
    forall m a. Monoid m => (a -> m) -> Item a -> m
    forall b a. (b -> a -> b) -> b -> Item a -> b
    forall a b. (a -> b -> b) -> b -> Item a -> b
    forall (t :: * -> *).
    (forall m. Monoid m => t m -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. t a -> [a])
    -> (forall a. t a -> Bool)
    -> (forall a. t a -> Int)
    -> (forall a. Eq a => a -> t a -> Bool)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> Foldable t
    $cfold :: forall m. Monoid m => Item m -> m
    fold :: forall m. Monoid m => Item m -> m
    $cfoldMap :: forall m a. Monoid m => (a -> m) -> Item a -> m
    foldMap :: forall m a. Monoid m => (a -> m) -> Item a -> m
    $cfoldMap' :: forall m a. Monoid m => (a -> m) -> Item a -> m
    foldMap' :: forall m a. Monoid m => (a -> m) -> Item a -> m
    $cfoldr :: forall a b. (a -> b -> b) -> b -> Item a -> b
    foldr :: forall a b. (a -> b -> b) -> b -> Item a -> b
    $cfoldr' :: forall a b. (a -> b -> b) -> b -> Item a -> b
    foldr' :: forall a b. (a -> b -> b) -> b -> Item a -> b
    $cfoldl :: forall b a. (b -> a -> b) -> b -> Item a -> b
    foldl :: forall b a. (b -> a -> b) -> b -> Item a -> b
    $cfoldl' :: forall b a. (b -> a -> b) -> b -> Item a -> b
    foldl' :: forall b a. (b -> a -> b) -> b -> Item a -> b
    $cfoldr1 :: forall a. (a -> a -> a) -> Item a -> a
    foldr1 :: forall a. (a -> a -> a) -> Item a -> a
    $cfoldl1 :: forall a. (a -> a -> a) -> Item a -> a
    foldl1 :: forall a. (a -> a -> a) -> Item a -> a
    $ctoList :: forall a. Item a -> [a]
    toList :: forall a. Item a -> [a]
    $cnull :: forall a. Item a -> Bool
    null :: forall a. Item a -> Bool
    $clength :: forall a. Item a -> Int
    length :: forall a. Item a -> Int
    $celem :: forall a. Eq a => a -> Item a -> Bool
    elem :: forall a. Eq a => a -> Item a -> Bool
    $cmaximum :: forall a. Ord a => Item a -> a
    maximum :: forall a. Ord a => Item a -> a
    $cminimum :: forall a. Ord a => Item a -> a
    minimum :: forall a. Ord a => Item a -> a
    $csum :: forall a. Num a => Item a -> a
    sum :: forall a. Num a => Item a -> a
    $cproduct :: forall a. Num a => Item a -> a
    product :: forall a. Num a => Item a -> a
    Foldable, Functor Item
    Foldable Item
    (Functor Item, Foldable Item) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> Item a -> f (Item b))
    -> (forall (f :: * -> *) a.
        Applicative f =>
        Item (f a) -> f (Item a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> Item a -> m (Item b))
    -> (forall (m :: * -> *) a. Monad m => Item (m a) -> m (Item a))
    -> Traversable Item
    forall (t :: * -> *).
    (Functor t, Foldable t) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> t a -> f (t b))
    -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> t a -> m (t b))
    -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
    -> Traversable t
    forall (m :: * -> *) a. Monad m => Item (m a) -> m (Item a)
    forall (f :: * -> *) a. Applicative f => Item (f a) -> f (Item a)
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Item a -> m (Item b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Item a -> f (Item b)
    $ctraverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Item a -> f (Item b)
    traverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Item a -> f (Item b)
    $csequenceA :: forall (f :: * -> *) a. Applicative f => Item (f a) -> f (Item a)
    sequenceA :: forall (f :: * -> *) a. Applicative f => Item (f a) -> f (Item a)
    $cmapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Item a -> m (Item b)
    mapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Item a -> m (Item b)
    $csequence :: forall (m :: * -> *) a. Monad m => Item (m a) -> m (Item a)
    sequence :: forall (m :: * -> *) a. Monad m => Item (m a) -> m (Item a)
    Traversable)

    --------------------------------------------------------------------------------
    instance Binary a => Binary (Item a) where
        put :: Item a -> Put
    put (Item Identifier
    i a
    x) = Identifier -> Put
    forall t. Binary t => t -> Put
    put Identifier
    i Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> a -> Put
    forall t. Binary t => t -> Put
    put a
    x
        get :: Get (Item a)
    get            = Identifier -> a -> Item a
    forall a. Identifier -> a -> Item a
    Item (Identifier -> a -> Item a) -> Get Identifier -> Get (a -> Item a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Get Identifier
    forall t. Binary t => Get t
    get Get (a -> Item a) -> Get a -> Get (Item a)
    forall a b. Get (a -> b) -> Get a -> Get b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Get a
    forall t. Binary t => Get t
    get

    --------------------------------------------------------------------------------
    itemSetBody :: a -> Item b -> Item a
    itemSetBody :: forall a b. a -> Item b -> Item a
    itemSetBody a
    x (Item Identifier
    i b
    _) = Identifier -> a -> Item a
    forall a. Identifier -> a -> Item a
    Item Identifier
    i a
    x

    --------------------------------------------------------------------------------
    -- | Perform a compiler action on the item body. This is the same as 'traverse',
    -- but looks less intimidating.
    --
    -- > withItemBody = traverse
    withItemBody :: (a -> Compiler b) -> Item a -> Compiler (Item b)
    withItemBody :: forall a b. (a -> Compiler b) -> Item a -> Compiler (Item b)
    withItemBody = (a -> Compiler b) -> Item a -> Compiler (Item b)
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Item a -> f (Item b)
    traverse