| Maintainer | hapytexeu+gh@gmail.com |
|---|---|
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Text.Comma
Description
This module provides functions to join elements of string-like types by adding a comma between the elements, and an "and" (optionally with a comma) between the one-but-last and the last element.
Synopsis
- comma_ :: IsString s => s
- and_ :: IsString s => s
- commaAnd_ :: IsString s => s
- data CommaStyle
- lastJoin :: IsString s => CommaStyle -> s
- commaAs :: (IsString s, Monoid s, Foldable f) => CommaStyle -> f s -> s
- commaEmptyAs :: (IsString s, Semigroup s, Foldable f) => s -> CommaStyle -> f s -> s
- comma :: (IsString s, Monoid s, Foldable f) => f s -> s
- noComma :: (IsString s, Monoid s, Foldable f) => f s -> s
- commaEmpty :: (IsString s, Semigroup s, Foldable f) => s -> f s -> s
- noCommaEmpty :: (IsString s, Semigroup s, Foldable f) => s -> f s -> s
- combineWith :: (Monoid s, Foldable f) => s -> s -> f s -> s
- combineWithEmpty :: (Semigroup s, Foldable f) => s -> s -> s -> f s -> s
Documentation
Arguments
| :: IsString s | |
| => s | A string-like type. |
The string-like value for a comma, so ", ".
Arguments
| :: IsString s | |
| => s | A string-like type. |
The string-like value for an "and", so " and ".
Arguments
| :: IsString s | |
| => s | A string-like type. |
The string-like value for a comma and an "and", so ", and ".
data CommaStyle Source #
The two different ways to join the last two items together: with or without a comma.
Constructors
| OxfordComma | The Oxford comma which uses a comma before the latest element, also known as Harvard comma or series comma. |
| NoComma | The comma style where there is no comma before the "and" of the last item, informally known as the Heathen comma. |
Instances
Arguments
| :: IsString s | |
| => CommaStyle | The given comma style. |
| -> s | A string that specifies how to join the last but one item and the last item based on the comma style. |
Specify the string that determines how to join the last but one and the last item based on the CommaStyle.
commaAs :: (IsString s, Monoid s, Foldable f) => CommaStyle -> f s -> s Source #
Join the sequence of items with the given comma style, uses the empty string if there are no items.
commaEmptyAs :: (IsString s, Semigroup s, Foldable f) => s -> CommaStyle -> f s -> s Source #
Join the sequence of items with the given comma style, uses a given "string" if there are no items.
comma :: (IsString s, Monoid s, Foldable f) => f s -> s Source #
Joins the sequence of items with the Oxford comma style, uses the empty string if there are no items.
noComma :: (IsString s, Monoid s, Foldable f) => f s -> s Source #
Joins the sequence of items with the no comma style, uses the empty string if there are no items.
commaEmpty :: (IsString s, Semigroup s, Foldable f) => s -> f s -> s Source #
Join the sequence of items with the Oxford comma style, uses a given "string" if there are no items.
noCommaEmpty :: (IsString s, Semigroup s, Foldable f) => s -> f s -> s Source #
Join the sequence of items with the no comma style, uses a given "string" if there are no items.
Arguments
| :: (Monoid s, Foldable f) | |
| => s | The comma item placed between each item and the next, except for the last join. |
| -> s | The item used to join the one but last item and the last item. |
| -> f s | The |
| -> s | The item generated by joining the elements with the comma and last join item. |
Join the Foldable of elements with a given item for a comma and for the last join.
Arguments
| :: (Semigroup s, Foldable f) | |
| => s | The item used if the foldable item is empty. |
| -> s | The comma item placed between each item and the next, except for the last join. |
| -> s | The item used to join the one but last item and the last item. |
| -> f s | The |
| -> s | The item generated by joining the elements with the comma and last join item. |