vector-0.13.2.0: Efficient Arrays

Copyright | (c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022
License | BSD-style
Maintainer | Haskell Libraries Team <libraries@haskell.org>
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Data.Vector.Fusion.Bundle.Size

Description

Size hints for streams.

Synopsis

- data Size
  - = Exact !Int
  - | Max !Int
  - | Unknown
- clampedSubtract :: Size -> Size -> Size
- smaller :: Size -> Size -> Size
- smallerThan :: Int -> Size -> Size
- larger :: Size -> Size -> Size
- toMax :: Size -> Size
- upperBound :: Size -> Maybe Int
- lowerBound :: Size -> Int

# Documentation

data Size Source #

Size hint

Constructors

Exact !Int | Exact size
Max !Int | Upper bound on the size
Unknown | Unknown size

#### Instances

Instances details

Num Size Source # |
Instance details Defined in Data.Vector.Fusion.Bundle.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.Vector.Fusion.Bundle.Size Methods showsPrec :: Int -> Size -> ShowS Source # show :: Size -> String Source # showList :: [Size] -> ShowS Source #
Eq Size Source # |
Instance details Defined in Data.Vector.Fusion.Bundle.Size Methods (==) :: Size -> Size -> Bool Source # (/=) :: Size -> Size -> Bool Source #

clampedSubtract :: Size -> Size -> Size Source #

Subtract two sizes with clamping to 0, for drop-like things

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

Minimum of two size hints

smallerThan :: Int -> Size -> Size Source #

Select a safe smaller than known size.

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

Maximum of two size hints

toMax :: Size -> Size Source #

Convert a size hint to an upper bound

upperBound :: Size -> Maybe Int Source #

Compute the maximum size from a size hint if possible

lowerBound :: Size -> Int Source #

Compute the minimum size from a size hint