    module Data.List.Extended
        ( module Data.List
        , breakWhen
        ) where

    import           Data.List

    -- | Like 'break', but can act on the entire tail of the list.
    breakWhen :: ([a] -> Bool) -> [a] -> ([a], [a])
    breakWhen :: ([a] -> Bool) -> [a] -> ([a], [a])
    breakWhen predicate :: [a] -> Bool
    predicate = [a] -> [a] -> ([a], [a])
    go []
      where
        go :: [a] -> [a] -> ([a], [a])
    go buf :: [a]
    buf []                = ([a] -> [a]
    forall a. [a] -> [a]
    reverse [a]
    buf, [])
        go buf :: [a]
    buf (x :: a
    x : xs :: [a]
    xs)
            | [a] -> Bool
    predicate (a
    x a -> [a] -> [a]
    forall a. a -> [a] -> [a]
    : [a]
    xs) = ([a] -> [a]
    forall a. [a] -> [a]
    reverse [a]
    buf, a
    x a -> [a] -> [a]
    forall a. a -> [a] -> [a]
    : [a]
    xs)
            | Bool
    otherwise          = [a] -> [a] -> ([a], [a])
    go (a
    x a -> [a] -> [a]
    forall a. a -> [a] -> [a]
    : [a]
    buf) [a]
    xs