hask.lang.lazylist – A lazy List

class hask.lang.lazylist.Enum[source]

Class Enum defines operations on sequentially ordered types.

The enumFrom… methods are used in translation of arithmetic sequences.

Instances of Enum may be derived for any enumeration type (types whose constructors have no fields). The nullary constructors are assumed to be numbered left-to-right by fromEnum from 0 through n-1.

Attributes:

  • toEnum
  • fromEnum
  • succ
  • pred
  • enumFrom
  • enumFromThen
  • enumFrom
  • enumFromThenTo
  • EnumFromTo

Minimal complete definition:

  • toEnum
  • fromEnum
L

L is the syntactic construct for Haskell-style list comprehensions and lazy list creation. To create a new List, just wrap an interable in L[ ].

List comprehensions can be used with any instance of Enum, including the built-in types int, long (in Python 2), float, and str (a char).

There are four basic list comprehension patterns:

>>> from hask.lang import L
>>> # list from 1 to infinity, counting by ones
>>> L[1, ...]
L[1, ...]
>>> # list from 1 to infinity, counting by twos
>>> L[1, 3, ...]
L[1, 3, ...]
>>> # list from 1 to 20 (inclusive), counting by ones
>>> L[1, ..., 20]
L[1, ..., 20]
>>> # list from 1 to 20 (inclusive), counting by fours
>>> L[1, 5, ..., 20]
L[1, 5, ..., 20]
class hask.lang.lazylist.List(head=None, tail=None)[source]

Statically typed lazy sequence datatype.

See L for more information.