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

Safe HaskellNone
LanguageHaskell98

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
  • take :: C n => n -> [a] -> [a]
  • drop :: C n => n -> [a] -> [a]
  • splitAt :: C n => n -> [a] -> ([a], [a])
  • (!!) :: C n => [a] -> n -> a
  • zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

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

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

zipWith Source #

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.