Slist.Size

slist-0.2.1.0: Sized list

Copyright | (c) 2019-2020 Veronika Romashkina (c) 2020-2022 Kowainik
License | MPL-2.0
Maintainer | Kowainik <xrom.xkov@gmail.com>
Stability | Stable
Portability | Portable
Safe Haskell | None
Language | Haskell2010

Slist.Size

Description

Lists size representation.

Synopsis

- data Size
  - = Size !Int
  - | Infinity
- sizes :: Size -> [Size]

# Documentation

data Size #

Data type that represents lists size/lengths.

List | `length` | Size
--- | --- | ---
`[]` | `0` | `Size 0`
`[1..10]` | `10` | `Size 10`
`[1..]` | hangs | `Infinity`

Note, that size is not suppose to have negative value, so use the `Size` constructor carefully.

Constructors

Size !Int | Finite size
Infinity | Infinite size.

#### Instances

Instances details

Bounded Size # | The minimum possible size for the list is empty list: `Size 0` The maximum possible size is `Infinity`.
Instance details Defined in Slist.Size Methods minBound :: Size # maxBound :: Size #
Num Size # | Efficient implementations of numeric operations with `Size`s. Any operations with `Infinity` size results into `Infinity`. When `Infinity` is a left argument, all operations are also right-lazy. Operations are checked for integral overflow under the assumption that all values inside `Size` are positive.
    >>> Size 10 + Size 5
    Size 15
    >>> Size 5 * Infinity
    Infinity
    >>> Infinity + error "Unevaluated size"
    Infinity
    >>> Size (10 ^ 10) * Size (10 ^ 10)
    Infinity
Instance details Defined in Slist.Size Methods (+) :: Size -> Size -> Size # (-) :: Size -> Size -> Size # (*) :: Size -> Size -> Size # negate :: Size -> Size # abs :: Size -> Size # signum :: Size -> Size # fromInteger :: Integer -> Size #
Read Size # |
Instance details Defined in Slist.Size Methods readsPrec :: Int -> ReadS Size # readList :: ReadS [Size] # readPrec :: ReadPrec Size # readListPrec :: ReadPrec [Size] #
Show Size # |
Instance details Defined in Slist.Size Methods showsPrec :: Int -> Size -> ShowS # show :: Size -> String # showList :: [Size] -> ShowS #
Eq Size # |
Instance details Defined in Slist.Size Methods (==) :: Size -> Size -> Bool # (/=) :: Size -> Size -> Bool #
Ord Size # |
Instance details Defined in Slist.Size Methods compare :: Size -> Size -> Ordering # (<) :: Size -> Size -> Bool # (<=) :: Size -> Size -> Bool # (>) :: Size -> Size -> Bool # (>=) :: Size -> Size -> Bool # max :: Size -> Size -> Size # min :: Size -> Size -> Size #

sizes :: Size -> [Size] #

Returns the list of sizes from zero to the given one (including).

    >>> sizes $ Size 3
    [Size 0,Size 1,Size 2,Size 3]

    >> sizes Infinity
    [Size 0, Size 1, ..., Size maxBound, Infinity]