Maintainer | hapytexeu+gh@gmail.com |
---|---|
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe |
Language | Haskell2010 |
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
- ratioToVulgar :: Integral i => Ratio i -> Maybe Char
- toVulgar :: (Integral i, Integral j) => i -> j -> Maybe Char
- fromVulgar :: (Integral i, Integral j) => Char -> Maybe (i, j)
- fromVulgarToRatio :: Integral i => Char -> Maybe (Ratio i)
- ratioToVulgarFallback :: Integral i => Ratio i -> Text
- toVulgarFallback :: (Integral i, Integral j) => i -> j -> Text
- fromVulgarFallback :: (Read i, Integral i, Read j, Integral j) => Text -> Maybe (i, j)
- fromVulgarFallbackToRatio :: (Read i, Integral i) => Text -> Maybe (Ratio i)
Render to a vulgar fraction
:: (Integral i, Integral j) | |
=> i | The given numerator. |
-> j | The given denominator. |
-> Maybe Char | The corresponding |
Convert the given numerator den denominator to a vulgar fraction character, if such character exists; Nothing
otherwise.
Try to parse a vulgar fraction
Render to a vulgar fraction, with a fallback to using small characters
ratioToVulgarFallback Source #
:: Integral i | |
=> Ratio i | The given |
-> Text | A |
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 Char
acters) that looks like a fraction.
:: (Integral i, Integral j) | |
=> i | The given numerator. |
-> j | The given denominator. |
-> Text | A |
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 Char
acters) 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
:: (Read i, Integral i, Read j, Integral j) | |
=> Text | The |
-> Maybe (i, j) | A 2-tuple with the numerator and denominator wrapped in a |
Try to parse the text as a vulgar fraction and fallback on the unicodeToRatioParts
function to parse it as a fraction.
fromVulgarFallbackToRatio Source #
:: (Read i, Integral i) | |
=> Text | The |
-> Maybe (Ratio i) | The parsed |
Try to parse the text as a vulgar fraction and fallback on the unicodeToRatioParts
function to parse it as a fraction.