unicode-tricks-0.14.1.0: Functions to work with unicode blocks more convenient.
Maintainerhapytexeu+gh@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

Data.Char.Small

Description

One can make use of a block of Unicode characters to emulate subscript and superscript. Note that the subscript and superscript will be aligned with the baseline and the cap line respectively, and is thus not equivalent to sub.../sub and sup.../sup in HTML. Furthermore only a small subset of characters is supported.

This module allows one to map certain characters to their subscript and superscript counterpart, and furthermore makes it more convenient to transform a number (both positive and negative) to a Text that specifies this number in subscript and superscript.

Synopsis

Convert characters to their subscript and superscript counterpart

toSub Source #

Arguments

:: Char

The given character to convert to its subscript counterpart.

-> Maybe Char

A character wrapped in a Just given the counterpart exists, Nothing otherwise.

Convert a set of characters to their subscript counterpart, given that characters exists.

toSup Source #

Arguments

:: Char

The given character to convert to its superscript counterpart.

-> Maybe Char

A character wrapped in a Just given the counterpart exists, Nothing otherwise.

Convert a set of characters to their superscript counterpart, given that characters exists.

Convert superscript and subscript back their normal character

fromSubSup Source #

Arguments

:: Char

A character to un-subscript or un-superscript, for example '⁵'.

-> Char

The corresponding original character, for example '5'.

Convert subscripts and superscripts back to the original counterpart, so '⁵' back to '5'. For non-subscript or -superscript characters, it returns the original character.

Numbers as subscript and superscript.

asSub Source #

Arguments

:: Integral i 
=> PlusStyle

The given PlusStyle to use.

-> i

The given number to convert.

-> Text

A Text value that denotes the number as a sequence of subscript characters.

Convert a number (positive or negative) to a Text object that denotes that number in subscript characters.

asSub' Source #

Arguments

:: Integral i 
=> i

The number to convert.

-> Text

A Text value that contains the number as a sequence of subscript characters.

Convert a number (positive or negative) to a Text that specifies that number in subscript characters.

asSubPlus Source #

Arguments

:: Integral i 
=> i

The number to convert.

-> Text

A Text value that contains the number as a sequence of subscript characters.

Convert a number (positive or negative) to a Text that specifies that number in subscript characters. For positive characters, the subscript contains a plus character ().

asSup Source #

Arguments

:: Integral i 
=> PlusStyle

The given PlusStyle to use.

-> i

The given number to convert.

-> Text

A Text value that denotes the number as a sequence of superscript characters.

Convert a number (positive or negative) to a Text object that denotes that number in superscript characters.

asSup' Source #

Arguments

:: Integral i 
=> i

The number to convert.

-> Text

A Text value that contains the number as a sequence of superscript characters.

Convert a number (positive or negative) to a Text object that denotes that number in superscript characters.

asSupPlus Source #

Arguments

:: Integral i 
=> i

The number to convert.

-> Text

A Text value that contains the number as a sequence of superscript characters.

Convert a number (positive or negative) to a Text that specifies that number in superscript characters. For positive characters, the superscript contains a plus character ().

Ratio formatting

ratioToUnicode Source #

Arguments

:: Integral i 
=> PlusStyle

The given PlusStyle to use.

-> Ratio i

The given Ratio object to convert to a Text.

-> Text

A Text object that denotes the given Ratio making use of superscript and subscript.

Convert the given Ratio object to a sequence of characters with the numerator in superscript and the denominator in subscript. The given PlusStyle is applied to the numerator.

ratioToUnicode' Source #

Arguments

:: Integral i 
=> Ratio i

The given Ratio value to format.

-> Text

The Text block that contains a textual representation of the Ratio.

Format a given Ratio object to a Text value that formats the ratio with superscript and subscript using the Default PlusStyle.

ratioPartsToUnicode Source #

Arguments

:: (Integral i, Integral j) 
=> PlusStyle

the given plus style that will be applied to the numerator.

-> i

The given numerator.

-> j

The given denominator.

-> Text

A Text object that presents the fraction with superscript and subscript.

Converting the given numerator and denominator to a fraction where the numerator is written in superscript, and the denominator in subscript. If the denominator is negative, the item is rendered with a minus at the numerator part.

ratioPartsToUnicode' Source #

Arguments

:: (Integral i, Integral j) 
=> i

The given numerator.

-> j

The given denominator.

-> Text

A Text object that presents the fraction with superscript and subscript.

Converting the given numerator and denominator to a fraction where the numerator is written in superscript, and the denominator in subscript. If the denominator is negative, the item is rendered with a minus at the numerator part.

Ratio parsing

unicodeToRatio Source #

Arguments

:: (Integral i, Read i) 
=> Text

The Text we try to decode.

-> Maybe (Ratio i)

The fraction wrapped in a Just; Nothing if the fraction can not be parsed.

Try to convert the given text that contains a fraction to a Ratio. This does *not* take vulgar fractions into account. You can process these with fromVulgarFallbackToRatio.

unicodeToRatioParts Source #

Arguments

:: (Read i, Read j) 
=> Text

The Text we try to decode.

-> Maybe (i, j)

A 2-tuple with the numerator and denominator wrapped in a Just if the fraction can be parsed, Nothing otherwise.

Try to convert the given text that contains a fraction to the numerator and denominator. This does *not* take vulgar fractions into account. You can process these with fromVulgarFallback.