Skip to content

Commit

Permalink
Explicitly implement sconcat in Semigroup instances
Browse files Browse the repository at this point in the history
Since `stimes` was explicitly implemented in haskell#611:
Closes haskell#488. Closes haskell#489.
  • Loading branch information
clyring committed Jan 31, 2024
1 parent 44375fa commit 5d1a2d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Data/ByteString/Builder/Internal.hs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 5d1a2d7

Please sign in to comment.