failable-list-0.2: A list-like type for lazy streams, which might terminate with an error.

Portabilityportable
Maintainerjmillikin@gmail.com

Data.FailableList

Description

A list-like type for lazy streams, which might terminate with an error.

This module uses common names and so is designed to be imported qualified:

 import qualified Data.FailableList as FL

Synopsis

Documentation

data FailableList e a Source

A list-like type for lazy sequences which might terminate with an error.

Standard lists can be converted to failable lists using Prelude.foldr Next Done.

Constructors

Next a (FailableList e a) 
Done 
Fail e 

null :: FailableList e a -> BoolSource

Like the standard null function.

append :: FailableList e a -> FailableList e a -> FailableList e aSource

Like the standard ++ function.

map :: (a -> b) -> FailableList e a -> FailableList e bSource

Like the standard map function.

mapEither :: (a -> Either e b) -> FailableList e a -> FailableList e bSource

Like the standard map function, but the mapping function may return an error.

concatMap :: (a -> FailableList e b) -> FailableList e a -> FailableList e bSource

Like the standard concatMap function.

foldr :: (a -> b -> b) -> b -> (e -> b) -> FailableList e a -> bSource

Like the standard foldr function, but accepting an extra parameter to handle Fail items.

foldl :: (b -> a -> b) -> b -> FailableList e a -> Either e bSource

Like the standard foldl function, but errors will return a Left value.

unfoldr :: (b -> Either e (Maybe (a, b))) -> b -> FailableList e aSource

Like the standard Data.List.unfoldr function, but the step function may return an error.

length :: FailableList e a -> IntSource

Like the standard length function; Done and Fail are considered 0-length.