From b41b49bd7129775944fdf6305db513c1a1648ff2 Mon Sep 17 00:00:00 2001 From: erkok Date: Sat, 12 Oct 2002 18:16:11 +0000 Subject: [PATCH] [project @ 2002-10-12 18:16:11 by erkok] mdo wibbles --- ghc/docs/users_guide/glasgow_exts.sgml | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/ghc/docs/users_guide/glasgow_exts.sgml b/ghc/docs/users_guide/glasgow_exts.sgml index 5c3e74e..a8d7051 100644 --- a/ghc/docs/users_guide/glasgow_exts.sgml +++ b/ghc/docs/users_guide/glasgow_exts.sgml @@ -357,6 +357,8 @@ the do-notation, and this extension provides the necessary syntactic support. Here is a simple (yet contrived) example: +import Control.Monad.Fix + justOnes = mdo xs <- Just (1:xs) return xs @@ -378,8 +380,9 @@ then that monad must be declared an instance of the MonadFix For details, see the above mentioned reference. -The following instances of MonadFix are automatically provided: List, Maybe, IO, and -state monads (both lazy and strict). +The following instances of MonadFix are automatically provided: List, Maybe, IO. +Furthermore, the Control.Monad.ST and Control.Monad.ST.Lazy modules provide the instances of the MonadFix class +for Haskell's internal state monad (strict and lazy, respectively). There are three important points in using the recursive-do notation: @@ -390,14 +393,10 @@ than do). -If you want to declare an instance of the MonadFix class for one of -your own monads, or you need to refer to the class name MonadFix in any other way (for -instance when writing a type constraint), then your program should -import Control.Monad.MonadFix. -Otherwise, you don't need to import any special libraries to use the mdo-notation. That is, -as long as you only use the predefined instances mentioned above, the mdo-notation will -be automatically available. -To be on the safe side, of course, you can simply import it in all cases. +You should import Control.Monad.Fix. +(Note: Strictly speaking, this import is required only when you need to refer to the name +MonadFix in your program, but the import is always safe, and the programmers +are encouraged to always import this module when using the mdo-notation.) @@ -407,15 +406,15 @@ As with other extensions, ghc should be given the flag -fglasgow-exts -Historical note: The old implementation of the mdo-notation (and most -of the existing documents) used the name -MonadRec for the class and the corresponding library. -This name is no longer supported. +The web page: http://www.cse.ogi.edu/PacSoft/projects/rmb +contains up to date information on recursive monadic bindings. -The web page: http://www.cse.ogi.edu/PacSoft/projects/rmb -contains up to date information on recursive monadic bindings. +Historical note: The old implementation of the mdo-notation (and most +of the existing documents) used the name +MonadRec for the class and the corresponding library. +This name is not supported by GHC. -- 1.7.10.4