
23 May
2008
23 May
'08
3:28 a.m.
On Fri, May 23, 2008 at 09:03:29AM +0200, Krasimir Angelov wrote:
Alternatively I can use monad with failure. In other words, there are two possibilities:
1. Use error ".." and types like: TreeLoc a -> TreeLoc a 2. Use monad and type like: Monad m => TreeLoc a -> m (TreeLoc a)
I'd suggest that TreeLoc a -> Maybe (TreeLoc a) is better than the second version. The problem with using Monad(fail) is that it hides possible runtime errors among testable conditions. With 1. you can at least search the code for occurrences of the dangerous function. With the Monad version you need to consider the type of each use to know whether it is dangerous.