Skip to content

Commit e7de566

Browse files
Expan on Semigroup's documentation to explain purposes behind newtypes
1 parent c48a6e6 commit e7de566

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Data/Semigroup.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ import Type.Data.RowList (RLProxy(..))
2020
-- | One example of a `Semigroup` is `String`, with `(<>)` defined as string
2121
-- | concatenation. Another example is `List a`, with `(<>)` defined as
2222
-- | list concatenation.
23+
-- |
24+
-- | There are two other ways to implement an instance for this type class
25+
-- | regardless of which type is used. These instances can be used by
26+
-- | wrapping the values in one of the two newtypes below:
27+
-- | 1. `First` - Use the first argument every time: `append first _ = first`.
28+
-- | 2. `Last` - Use the last argument every time: `append _ last = last`.
2329
class Semigroup a where
2430
append :: a -> a -> a
2531

0 commit comments

Comments
 (0)