Skip to content

Commit 29d5b87

Browse files
authored
Merge pull request #106 from shmish111/master
Add some examples to intercalate documentation
2 parents 1de5713 + 3abc134 commit 29d5b87

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Data/Foldable.purs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,19 @@ oneOfMap f = foldr (alt <<< f) empty
240240

241241
-- | Fold a data structure, accumulating values in some `Monoid`,
242242
-- | combining adjacent elements using the specified separator.
243+
-- |
244+
-- | For example:
245+
-- |
246+
-- | ```purescript
247+
-- | > intercalate ", " ["Lorem", "ipsum", "dolor"]
248+
-- | = "Lorem, ipsum, dolor"
249+
-- |
250+
-- | > intercalate "*" ["a", "b", "c"]
251+
-- | = "a*b*c"
252+
-- |
253+
-- | > intercalate [1] [[2, 3], [4, 5], [6, 7]]
254+
-- | = [2, 3, 1, 4, 5, 1, 6, 7]
255+
-- | ```
243256
intercalate :: forall f m. Foldable f => Monoid m => m -> f m -> m
244257
intercalate sep xs = (foldl go { init: true, acc: mempty } xs).acc
245258
where

0 commit comments

Comments
 (0)