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

Slist.Size

Description

Lists size representation.

Synopsis

Documentation

data Size Source #

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 Source #

The minimum possible size for the list is empty list: Size 0 The maximum possible size is Infinity.

Instance details

Defined in Slist.Size

Eq Size Source # 
Instance details

Defined in Slist.Size

Methods

(==) :: Size -> Size -> Bool #

(/=) :: Size -> Size -> Bool #

Num Size Source #

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 #

Ord Size Source # 
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 #

Read Size Source # 
Instance details

Defined in Slist.Size

Show Size Source # 
Instance details

Defined in Slist.Size

Methods

showsPrec :: Int -> Size -> ShowS #

show :: Size -> String #

showList :: [Size] -> ShowS #

sizes :: Size -> [Size] Source #

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]