> The construct I want is:
> 
> error1 :: String -> String -> a 
> 
> where the first string says what should be seen (without stopping the
> program) when one tries to show it, the other what should be 
> seen (with
> stopping the program) when trying to evaluate it.

But in order to show it, you have to evaluate it.  You can't have a value
which is both _|_ and non-_|_ at the same time.

However, in GHC you can detect and recover from certain kinds of _|_.  Take
a look at the Exception library, in hslib "lang".

You could define error1 as

        error1 s1 s2 = throwDyn (MyError s1 s2)

and write a show function which catches MyError.  The show function should
be in the IO monad, and it will need to evaluate each part of the tree
inside an exception handler before printing it.

Hope this helps,
        
Simon

Reply via email to