comma-and-0.1.0.1: Join text together with commas, and "and".
Maintainerhapytexeu+gh@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

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

Documentation

comma_ Source #

Arguments

:: IsString s 
=> s

A string-like type.

The string-like value for a comma, so ", ".

and_ Source #

Arguments

:: IsString s 
=> s

A string-like type.

The string-like value for an "and", so " and ".

commaAnd_ Source #

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

Instances details
Bounded CommaStyle Source # 
Instance details

Defined in Text.Comma

Enum CommaStyle Source # 
Instance details

Defined in Text.Comma

Read CommaStyle Source # 
Instance details

Defined in Text.Comma

Show CommaStyle Source # 
Instance details

Defined in Text.Comma

Default CommaStyle Source # 
Instance details

Defined in Text.Comma

Methods

def :: CommaStyle #

Eq CommaStyle Source # 
Instance details

Defined in Text.Comma

Ord CommaStyle Source # 
Instance details

Defined in Text.Comma

lastJoin Source #

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.

combineWith Source #

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 Foldable of items that should be joined.

-> 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.

combineWithEmpty Source #

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 Foldable of items that should be joined.

-> 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 with a custom value if the Foldable is empty.