text-2.0.2: An efficient packed Unicode text type.

Copyright | (c) Roman Leshchinskiy 2008 (c) Bryan O'Sullivan 2009
License | BSD-style
Maintainer | bos@serpentine.com
Stability | experimental
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Text.Internal.Fusion.Size

Contents

- Sizes
- Querying sizes

Description

Warning: this is an internal module, and does not have a stable API or name. Functions in this module may not check or enforce preconditions expected by public modules. Use at your own risk!

Size hints.

Synopsis

- data Size
- exactSize :: Int -> Size
- maxSize :: Int -> Size
- betweenSize :: Int -> Int -> Size
- unknownSize :: Size
- unionSize :: Size -> Size -> Size
- charSize :: Char -> Size
- codePointsSize :: Int -> Size
- exactly :: Size -> Maybe Int
- smaller :: Size -> Size -> Size
- larger :: Size -> Size -> Size
- upperBound :: Int -> Size -> Int
- lowerBound :: Int -> Size -> Int
- compareSize :: Size -> Size -> Maybe Ordering
- isEmpty :: Size -> Bool

# Documentation

data Size Source #

A size in UTF-8 code units (which is bytes).

#### Instances

Instances details

Num Size Source # |
Instance details Defined in Data.Text.Internal.Fusion.Size Methods (+) :: Size -> Size -> Size Source # (-) :: Size -> Size -> Size Source # (*) :: Size -> Size -> Size Source # negate :: Size -> Size Source # abs :: Size -> Size Source # signum :: Size -> Size Source # fromInteger :: Integer -> Size Source #
Show Size Source # |
Instance details Defined in Data.Text.Internal.Fusion.Size Methods showsPrec :: Int -> Size -> ShowS Source # show :: Size -> String Source # showList :: [Size] -> ShowS Source #
Eq Size Source # |
Instance details Defined in Data.Text.Internal.Fusion.Size Methods (==) :: Size -> Size -> Bool Source # (/=) :: Size -> Size -> Bool Source #

# Sizes

exactSize :: Int -> Size Source #

maxSize :: Int -> Size Source #

betweenSize :: Int -> Int -> Size Source #

unknownSize :: Size Source #

unionSize :: Size -> Size -> Size Source #

charSize :: Char -> Size Source #

The `Size` of the given code point.

codePointsSize :: Int -> Size Source #

The `Size` of `n` code points.

# Querying sizes

exactly :: Size -> Maybe Int Source #

smaller :: Size -> Size -> Size Source #

Minimum of two size hints.

larger :: Size -> Size -> Size Source #

Maximum of two size hints.

upperBound :: Int -> Size -> Int Source #

Compute the maximum size from a size hint, if possible.

lowerBound :: Int -> Size -> Int Source #

Compute the minimum size from a size hint, if possible.

compareSize :: Size -> Size -> Maybe Ordering Source #

Determine the ordering relationship between two `Size`s, or `Nothing` in the indeterminate case.

isEmpty :: Size -> Bool Source #