slist-0.2.1.0: Sized list
Copyright(c) 2019-2020 Veronika Romashkina
(c) 2020-2022 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellNone
LanguageHaskell2010

Slist.Size

Description

Lists size representation.

Synopsis

Documentation

data Size #

Data type that represents lists size/lengths.

ListlengthSize
[]0Size 0
[1..10]10Size 10
[1..]hangsInfinity

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

Num Size #

Efficient implementations of numeric operations with Sizes.

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

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]