[Haskell-cafe] How to catch exception within the Get monad(theBinary package)

Donn Cave donn at avvanta.com
Tue Sep 7 19:13:11 EDT 2010

Quoth Donn Cave <donn at avvanta.com>,
> I think it's very likely there's a simpler way to do this with
> Data.Serial as written, I am just a little backwards with state
> monads and that kind of thing.

OK, another look at it reveals that "mplus" can be used for this
application, so much more simply,

    import Control.Monad (mplus)

    getx = do
	a <- get
	x <- getn `mplus` return []
	return (a:x)

	Donn Cave, donn at avvanta.com

More information about the Haskell-Cafe mailing list