-- | Create a 'Tagged' from a list of values with optional tags
fromAssocList :: [(Maybe t, a)] -> Tagged t a
fromAssocList = mconcat . map f
  where
    f (Nothing, a) = untag a
    f (Just t,  a) = tag t a


-- * Destructors

-- | Reduce a 'Tagged' to a list, using a function on tagless values and a
-- function on tagged values.
fromAssocList :: [(Maybe t, a)] -> Tagged t a
fromAssocList = mconcat . map f
  where
    f (Nothing, a) = untag a
    f (Just t,  a) = tag t a


-- * Destructors

-- | Reduce a 'Tagged' to a list, using a function on tagless values and a
-- function on tagged values.
fromAssocList = mconcat . map f
  where
    f (Nothing, a) = untag a
    f (Just t,  a) = tag t a


-- * Destructors

-- | Reduce a 'Tagged' to a list, using a function on tagless values and a
-- function on tagged values.