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

Safe HaskellNone
LanguageHaskell98

NumericPrelude.List.Generic

Description

Functions that are counterparts of the generic functions in Data.List using NumericPrelude.Numeric type classes. For input arguments we use the restrictive ToInteger constraint, although in principle RealRing would be enough. However we think that take 0.5 xs is rather a bug than a feature, thus we forbid fractional types. On the other hand fractional types as result can be quite handy, e.g. in average xs = sum xs / length xs.

Synopsis

Documentation

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

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

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

Left associative length computation that is appropriate for types like Integer.

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

Right associative length computation that is appropriate for types like Peano number.

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

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

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

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

findIndex :: C n => (a -> Bool) -> [a] -> Maybe n Source

elemIndex :: (C n, Eq a) => a -> [a] -> Maybe n Source

findIndices :: C n => (a -> Bool) -> [a] -> [n] Source

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