slist-0.1.1.0: Sized list

Copyright(c) 2019-2020 Veronika Romashkina
LicenseMPL-2.0
MaintainerVeronika Romashkina <vrom911@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Slist.Size

Description

Lists size representation.

Synopsis

Documentation

data Size Source #

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
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.

TODO: checking on overflow when + or * sizes.

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]