failable-list-0.1: 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 

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

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

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.

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.