    -----------------------------------------------------------------------------
    -- |
    -- Module      :  Distribution.Compat.SnocList
    -- License     :  BSD3
    --
    -- Maintainer  :  cabal-dev@haskell.org
    -- Stability   :  experimental
    -- Portability :  portable
    --
    -- A very reversed list. Has efficient `snoc`
    module Distribution.Compat.SnocList (
        SnocList,
        runSnocList,
        snoc,
    ) where

    import Prelude ()
    import Distribution.Compat.Prelude

    newtype SnocList a = SnocList [a]

    snoc :: SnocList a -> a -> SnocList a
    snoc :: forall a. SnocList a -> a -> SnocList a
    snoc (SnocList [a]
    xs) a
    x = forall a. [a] -> SnocList a
    SnocList (a
    x forall a. a -> [a] -> [a]
    : [a]
    xs)

    runSnocList :: SnocList a -> [a]
    runSnocList :: forall a. SnocList a -> [a]
    runSnocList (SnocList [a]
    xs) = forall a. [a] -> [a]
    reverse [a]
    xs

    instance Semigroup (SnocList a) where
        SnocList [a]
    xs <> :: SnocList a -> SnocList a -> SnocList a
    <> SnocList [a]
    ys = forall a. [a] -> SnocList a
    SnocList ([a]
    ys forall a. Semigroup a => a -> a -> a
    <> [a]
    xs)

    instance Monoid (SnocList a) where
        mempty :: SnocList a
    mempty = forall a. [a] -> SnocList a
    SnocList []
        mappend :: SnocList a -> SnocList a -> SnocList a
    mappend = forall a. Semigroup a => a -> a -> a
    (<>)