oseOrRetractMap
   :: (Foldable c, PersistEntity val, PersistEntityBackend val ~ SqlBackend)
   => EntityField val CommentId
   -> (val -> CommentId)
   -> c CommentId
   -> DB (Map CommentId val)
closeOrRetractMap comment_field comment_projection comment_ids =
    fmap (foldr step mempty) $
    select $
    from $ \c -> do
    where_ (c ^. comment_field `in_` valList comment_ids)
    return c
  where
    -- step :: Entity val -> Map CommentId val -> Map CommentId val
    step (Entity _ c) = M.insert (comment_projection c) c

-- | Given a collection of CommentId, make a map from CommentId to Entity
-- Ticket. Comments that are not tickets will simply not be in the map.
m
closeOrRetractMap
   :: (Foldable c, PersistEntity val, PersistEntityBackend val ~ SqlBackend)
   => EntityField val CommentId
   -> (val -> CommentId)
   -> c CommentId
   -> DB (Map CommentId val)
closeOrRetractMap comment_field comment_projection comment_ids =
    fmap (foldr step mempty) $
    select $
    from $ \c -> do
    where_ (c ^. comment_field `in_` valList comment_ids)
    return c
  where
    -- step :: Entity val -> Map CommentId val -> Map CommentId val
    step (Entity _ c) = M.insert (comment_projection c) c

-- | Given a collection of CommentId, make a map from CommentId to Entity
-- Ticket. Comments that are not tickets will simply not be in the map.
closeOrRetractMap comment_field comment_projection comment_ids =
    fmap (foldr step mempty) $
    select $
    from $ \c -> do
    where_ (c ^. comment_field `in_` valList comment_ids)
    return c
  where
    -- step :: Entity val -> Map CommentId val -> Map CommentId val
    step (Entity _ c) = M.insert (comment_projection c) c

-- | Given a collection of CommentId, make a map from CommentId to Entity
-- Ticket. Comments that are not tickets will simply not be in the map.