Hi,
Thanks to everybody who replied.
I see another solution: are there any hidden problems?
I found an interesting package, ChasingBottoms which contains a
function testing a value to be bottom and returning a Boolean (of
course it cannot be done without unsafePerformIO).
I borrowed the idea
Dimitry Golubovsky schrieb:
Hi,
Thanks to everybody who replied.
I see another solution: are there any hidden problems?
I found an interesting package, ChasingBottoms which contains a
function testing a value to be bottom and returning a Boolean (of
course it cannot be done without
On 07.09.2010 20:51, Henning Thielemann wrote:
This solution looks very ugly to me. Catching 'error's is debugging, but
parser failure is kind of exception handling. I guess, the errors you
want to catch are caused by non-supported fail method, right? Can't you
use a monad transformer like
On Tue, Sep 7, 2010 at 2:45 PM, Dimitry Golubovsky golubov...@gmail.com wrote:
unThrow a = unsafePerformIO $ (E.evaluate a = return . Right) `E.catch`
(\e - return $ Left e)
-- or perhaps the right argument of catch could be just (return . Left)?
Henning,
On Tue, Sep 7, 2010 at 12:51 PM, Henning Thielemann
schlepp...@henning-thielemann.de wrote:
This solution looks very ugly to me. Catching 'error's is debugging, but
parser failure is kind of exception handling. I guess, the errors you
want to catch are caused by non-supported fail
If however something goes wrong, and prs fails, the whole function
fails (error is thrown). Since [a] (result of decoding) is a lazy
list, actual exception may be thrown at any moment the list is being
processed, and exception handler may not be properly set.
True - return (reverse a)
False
On Sun, 5 Sep 2010, Dimitry Golubovsky wrote:
Hi,
The following function* is supposed to decode a list of some
serialized objects following each other in a lazy Bytestring:
many :: Get a - Get [a]
many prs = many' [] where
many' a = do
s - prs
r - isEmpty
case r of
True -
Also any half decent binary format should tell you how long the list
is *before* you parse it, either:
1) How many elements it has - for this you just need a counting
version of the many combinator.
2) The length of bytes that the flattened list takes. In this case the
repeating combinator has
If however something goes wrong, and prs fails, the whole function
fails (error is thrown). Since [a] (result of decoding) is a lazy
list, actual exception may be thrown at any moment the list is being
processed, and exception handler may not be properly set.
True - return (reverse a)
False