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

Description

Uncode has two blocks where vulgar fractions are defined: C1 controls and latin supplement 1 and Number forms. These are fractions that are commenly used.

The module exports function toVulgar and ratioToVulgar to convert the ratio to a Char with that fraction if that exists. The functon ratioToVulgarFallback and ratioToVulgarFallback are used to try to find a vulgar fraction character, and if that fails, it prints the fraction with the help of the Small module.

Synopsis

Render to a vulgar fraction

ratioToVulgar Source #

Arguments

:: Integral i 
=> Ratio i

The Ratio for which we try to find the corresponding Character.

-> Maybe Char

The corresponding Character wrapped in a Just if such character exists; Nothing otherwise.

Convert the given Ratio item to a vulgar fraction character, if such character exists; Nothing otherwise.

toVulgar Source #

Arguments

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

The given numerator.

-> j

The given denominator.

-> Maybe Char

The corresponding Character wrapped in a Just if such character exists; Nothing otherwise.

Convert the given numerator den denominator to a vulgar fraction character, if such character exists; Nothing otherwise.

Try to parse a vulgar fraction

fromVulgar Source #

Arguments

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

The character to decode.

-> Maybe (i, j)

The numerator and denominator wrapped in a Just if the character is a vulgar fraction, Nothing otherwise.

Try to convert a given Char, if it is a vulgar fraction, to a 2-tuple with the numerator and denominator. Returns Nothing if the Char is not a vulgar fraction character.

fromVulgarToRatio Source #

Arguments

:: Integral i 
=> Char

The character to decode.

-> Maybe (Ratio i)

The corresponding Ratio wrapped in a Just if the ratio is a vulgar fraction, Nothing otherwise.

Try to convert the given Char, if it is a vulgar fraction, to a Ratio object. Returns Nothing if the Char is not a vulgar fraction character.

Render to a vulgar fraction, with a fallback to using small characters

ratioToVulgarFallback Source #

Arguments

:: Integral i 
=> Ratio i

The given Ratio to convert.

-> Text

A Text object with a single Character if a vulgar fraction character exists; otherwise a Text object created by ratioPartsToUnicode'.

Convert the given Ratio to a singleton Text with the vulgar fraction character, if such character exists; it will make ue of the ratioPartsToUnicode' to generate a Text object (with multiple Characters) that looks like a fraction.

toVulgarFallback Source #

Arguments

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

The given numerator.

-> j

The given denominator.

-> Text

A Text object with a single Character if a vulgar fraction character exists; otherwise a Text object created by ratioPartsToUnicode'.

Convert the given numerator and denominator to a singleton Text with the vulgar fraction character, if such character exists; it will make ue of the ratioPartsToUnicode' to generate a Text object (with multiple Characters) that looks like a fraction.

Convert Text to a vulgar fraction or fallback on a Text that contains a numerator and denominator as a sequence of characters

fromVulgarFallback Source #

Arguments

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

The Text we try to decode as a (vulgar) fraction.

-> Maybe (i, j)

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

Try to parse the text as a vulgar fraction and fallback on the unicodeToRatioParts function to parse it as a fraction.

fromVulgarFallbackToRatio Source #

Arguments

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

The Text we try to decode as a (vulgar) fraction.

-> Maybe (Ratio i)

The parsed Ratio wrapped in a Just if the Text can be parsed, Nothing otherwise.

Try to parse the text as a vulgar fraction and fallback on the unicodeToRatioParts function to parse it as a fraction.