Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly implement sconcat in Semigroup instances #650

Merged
merged 1 commit into from Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Data/ByteString/Builder/Internal.hs
Expand Up @@ -129,6 +129,7 @@ module Data.ByteString.Builder.Internal (
import Control.Arrow (second)

import Data.Semigroup (Semigroup(..))
import Data.List.NonEmpty (NonEmpty(..))

import qualified Data.ByteString as S
import qualified Data.ByteString.Internal.Type as S
Expand Down Expand Up @@ -400,6 +401,7 @@ stimesNegativeErr
instance Semigroup Builder where
{-# INLINE (<>) #-}
(<>) = append
sconcat (b:|bs) = b <> foldr mappend mempty bs
{-# INLINE stimes #-}
stimes = stimesBuilder

Expand Down
3 changes: 3 additions & 0 deletions Data/ByteString/Short/Internal.hs
Expand Up @@ -179,6 +179,8 @@ import Data.Monoid
( Monoid(..) )
import Data.Semigroup
( Semigroup(..), stimesMonoid )
import Data.List.NonEmpty
( NonEmpty(..) )
import Data.String
( IsString(..) )
import Control.Applicative
Expand Down Expand Up @@ -309,6 +311,7 @@ instance Ord ShortByteString where

instance Semigroup ShortByteString where
(<>) = append
sconcat (b:|bs) = concat (b:bs)
stimes = stimesMonoid

instance Monoid ShortByteString where
Expand Down