numeric-prelude-0.2.2.1: An experimental alternative hierarchy of numeric type classes

NumericPrelude.List.Checked

Description

Some functions that are counterparts of functions from Data.List using NumericPrelude.Numeric type classes. They are distinct in that they check for valid arguments, e.g. the length argument of take must be at most the length of the input list. However, since many Haskell programs rely on the absence of such checks, we did not make these the default implementations as in NumericPrelude.List.Generic.

Synopsis

Documentation

take :: C n => n -> [a] -> [a]Source

Taken number of elements must be at most the length of the list, otherwise the end of the list is undefined.

drop :: C n => n -> [a] -> [a]Source

Dropped number of elements must be at most the length of the list, otherwise the end of the list is undefined.

splitAt :: C n => n -> [a] -> ([a], [a])Source

Split position must be at most the length of the list, otherwise the end of the first list and the second list are undefined.

(!!) :: C n => [a] -> n -> aSource

The index must be smaller than the length of the list, otherwise the result is undefined.

zipWithSource

Arguments

:: (a -> b -> c)

function applied to corresponding elements of the lists

-> [a] 
-> [b] 
-> [c] 

Zip two lists which must be of the same length. This is checked only lazily, that is unequal lengths are detected only if the list is evaluated completely. But it is more strict than zipWithPad undefined f since the latter one may succeed on unequal length list if f is lazy.