[Haskell-cafe] Newbie Q: Monad 'fail' and 'error'

Dmitri O.Kondratiev dokondr at gmail.com
Wed Jun 6 05:39:32 EDT 2007


Monad class contains declaration

*fail* :: String -> m a

and provides default implementation for 'fail' as:

fail s = error s

On the other hand Prelude defines:
*
error* :: String -> a

which stops execution and displays an error message.

Questions:
1) What value and type 'error' actually returns in:
error "some message" ?

2) How declaration
String -> m a
matches with
String -> a ?

3) In Maybe monad:
fail = Nothing

When and how 'fail' is used in Maybe monad?

Thanks!

-- 
Dmitri O. Kondratiev
dokondr at gmail.com
http://www.geocities.com/dkondr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070606/c1833f35/attachment.htm


More information about the Haskell-Cafe mailing list