... | ... | @@ -24,12 +24,23 @@ Introducing `Semigroup` as a superclass of `Monoid` has been proposed several ti |
|
|
The final API (suitable for Haskell Report inclusion) we want to end up with is
|
|
|
|
|
|
|
|
|
```
|
|
|
module Prelude
|
|
|
( Semigroup((<>))
|
|
|
, Monoid(mempty, mconcat)
|
|
|
-- …
|
|
|
) where
|
|
|
|
|
|
-- …
|
|
|
```
|
|
|
|
|
|
```
|
|
|
module Data.Semigroup where
|
|
|
|
|
|
class Semigroup a where
|
|
|
(<>) :: a -> a -> a
|
|
|
|
|
|
-- not (re)exported from Prelude
|
|
|
sconcat :: NonEmpty a -> a
|
|
|
sconcat (a :| as) = go a as
|
|
|
where
|
... | ... | @@ -37,6 +48,7 @@ class Semigroup a where |
|
|
go b [] = b
|
|
|
|
|
|
-- GHC extension, not needed for Haskell Report
|
|
|
-- & not (re)exported from Prelude
|
|
|
stimes :: Integral b => b -> a -> a
|
|
|
stimes y0 x0 = {- default impl -}
|
|
|
```
|
... | ... | @@ -51,6 +63,7 @@ class Semigroup a => Monoid a where |
|
|
mconcat = foldr (<>) mempty
|
|
|
|
|
|
-- GHC extension, not needed for Haskell Report
|
|
|
-- & not (re)exported from Prelude
|
|
|
mtimes :: Integral b => b -> a -> a
|
|
|
mtimes y0 x0 = {- default impl -}
|
|
|
|
... | ... | |