1 {-# OPTIONS -fno-implicit-prelude #-}
2 -----------------------------------------------------------------------------
4 -- Module : Control.Monad.Fix
5 -- Copyright : (c) Andy Gill 2001,
6 -- (c) Oregon Graduate Institute of Science and Technology, 2001
7 -- License : BSD-style (see the file libraries/core/LICENSE)
9 -- Maintainer : libraries@haskell.org
10 -- Stability : experimental
11 -- Portability : portable
13 -- $Id: Fix.hs,v 1.3 2002/03/14 12:09:49 simonmar Exp $
17 -- Inspired by the paper:
18 -- \em{Functional Programming with Overloading and
19 -- Higher-Order Polymorphism},
20 -- \A[HREF="http://www.cse.ogi.edu/~mpj"]{Mark P Jones},
21 -- Advanced School of Functional Programming, 1995.}
23 -----------------------------------------------------------------------------
25 module Control.Monad.Fix (
27 mfix -- :: (a -> m a) -> m a
29 fix -- :: (a -> a) -> a
32 #ifdef __GLASGOW_HASKELL__
33 -- MonadFix is needed by System.IO, so it is below the Prelude.
43 fix f = let x = f x in x
45 class (Monad m) => MonadFix m where
46 mfix :: (a -> m a) -> m a
48 instance MonadFix Maybe where
52 _ -> error "empty mfix argument"
55 instance MonadFix IO where