[Haskell-cafe] Laziness and Either

John Goerzen jgoerzen at complete.org
Mon Apr 21 16:42:39 EDT 2008

On Mon April 21 2008 3:26:04 pm Magnus Therning wrote:
> In order to allow lazy decoding I ended up exporting decode' as well:
>   decode' :: String -> [Maybe Word8]

I take it that in a situation like this, you'd have either:

[]   -- success with empty result

a list full of Just x
     -- success with valid results

a list with 0 or more Just x, followed by one Nothing
     -- an error

Makes sense to me.  What impact does this have on performance?

Also, I wonder if there is some call for tools in Data.Either to support this 
type of usage?  For example:

type EitherList a b = [Either a b]

then some functions such as, say, mapEither or foldEither that act like 
try/catch: a special function to use for an exception, and otherwise 
they "unwrap" the Right side passing it along to others.

-- John

More information about the Haskell-Cafe mailing list