valBinds vbs =
    withEpAnnNotUsed HsValBinds
#if MIN_VERSION_ghc(8,6,0)
        $ withNoAnnSortKey ValBinds
#else
        $ noExt ValBindsIn
#endif
            (listToBag $ map mkLocated binds)
            (map mkLocated sigs)
  where
    sigs = [s | SigV s <- vbs]
    binds = [b | BindV b <- vbs]

-- | A single function pattern match, including an optional "where" clause.
--
-- For example:
--
-- > f x
-- >    | cond = y
-- >    | otherwise = z
-- >  where
-- >    y = ...
-- >    z = ...
valBinds vbs =
    withEpAnnNotUsed HsValBinds
#if MIN_VERSION_ghc(8,6,0)
        $ withNoAnnSortKey ValBinds
#else
        $ noExt ValBindsIn
#endif
            (listToBag $ map mkLocated binds)
            (map mkLocated sigs)
  where
    sigs = [s | SigV s <- vbs]
    binds = [b | BindV b <- vbs]

-- | A single function pattern match, including an optional "where" clause.
--
-- For example:
--
-- > f x
-- >    | cond = y
-- >    | otherwise = z
-- >  where
-- >    y = ...
-- >    z = ...
valBinds vbs =
    withEpAnnNotUsed HsValBinds
#if MIN_VERSION_ghc(8,6,0)
        $ withNoAnnSortKey ValBinds
#else
        $ noExt ValBindsIn
#endif
            (listToBag $ map mkLocated binds)
            (map mkLocated sigs)
  where
    sigs = [s | SigV s <- vbs]
    binds = [b | BindV b <- vbs]

-- | A single function pattern match, including an optional "where" clause.
--
-- For example:
--
-- > f x
-- >    | cond = y
-- >    | otherwise = z
-- >  where
-- >    y = ...
-- >    z = ...