:: Maybe a -> [a] -package:basement

The maybeToList function returns an empty list when given Nothing or a singleton list when given Just.

Examples

Basic usage:
>>> maybeToList (Just 7)
[7]
>>> maybeToList Nothing
[]
One can use maybeToList to avoid pattern matching when combined with a function that (safely) works on lists:
>>> import GHC.Internal.Text.Read ( readMaybe )

>>> sum $ maybeToList (readMaybe "3")
3

>>> sum $ maybeToList (readMaybe "")
0
Analogous to maybeToList in Data.Maybe.
The maybeToList function returns an empty list when given Nothing or a singleton list when given Just.

Examples

Basic usage:
>>> maybeToList (Just 7)
[7]
>>> maybeToList Nothing
[]
One can use maybeToList to avoid pattern matching when combined with a function that (safely) works on lists:
>>> import Text.Read ( readMaybe )

>>> sum $ maybeToList (readMaybe "3")
3

>>> sum $ maybeToList (readMaybe "")
0
The maybeToList function returns an empty list when given Nothing or a singleton list when not given Nothing.

Examples

Basic usage:
>>> maybeToList (Just 7)
[7]
>>> maybeToList Nothing
[]
One can use maybeToList to avoid pattern matching when combined with a function that (safely) works on lists:
>>> import Text.Read ( readMaybe )

>>> sum $ maybeToList (readMaybe "3")
3

>>> sum $ maybeToList (readMaybe "")
0
List of elements of a structure, from left to right. If the entire list is intended to be reduced via a fold, just fold the structure directly bypassing the list.

Examples

Basic usage:
>>> toList Nothing
[]
>>> toList (Just 42)
[42]
>>> toList (Left "foo")
[]
>>> toList (Node (Leaf 5) 17 (Node Empty 12 (Leaf 8)))
[5,17,12,8]
For lists, toList is the identity:
>>> toList [1, 2, 3]
[1,2,3]
List of elements of a structure, from left to right. If the entire list is intended to be reduced via a fold, just fold the structure directly bypassing the list.

Examples

Basic usage:
>>> toList Nothing
[]
>>> toList (Just 42)
[42]
>>> toList (Left "foo")
[]
>>> toList (Node (Leaf 5) 17 (Node Empty 12 (Leaf 8)))
[5,17,12,8]
For lists, toList is the identity:
>>> toList [1, 2, 3]
[1,2,3]
@since base-4.8.0.0
List of elements of a structure, from left to right.
Convert a vector v to a list of scalars.
The above type is a generalization for:
sample :: Signal a -> [a]
Get an infinite list of samples from a Signal The elements in the list correspond to the values of the Signal at consecutive clock cycles
sample s == [s0, s1, s2, s3, ...
NB: This function is not synthesizable
O(n) Convert a vector to a list.
O(n) Convert a vector to a list
Convert vector to the list
Coerce while preserving the type index.
Given a Lift n constraint in a signature carried by m, sendM promotes arbitrary actions of type n a to m a. It is spiritually similar to lift from the MonadTrans typeclass.
O(n) Convert between different vector types.
O(n) Convert different vector types
Tail of vector. Examples:
>>> import Data.Complex

>>> tail (1,2,3) :: Complex Double
2.0 :+ 3.0
Convert between different vector types
O(1) First element of a vector in a monad. See indexM for an explanation of why this is useful.
O(1) Last element of a vector in a monad. See indexM for an explanation of why this is useful.
O(1) First element in a monad, without checking for empty vectors. See indexM for an explanation of why this is useful.
O(1) Last element in a monad, without checking for empty vectors. See indexM for an explanation of why this is useful.