A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/src/Control-Monad-Fix.html below:

Control/Monad/Fix.hs





















module Control.Monad.Fix (
        MonadFix(
           mfix 
         ),
        fix     
  ) where

import Prelude
import System.IO
import Control.Monad.Instances ()
import Data.Function (fix)
#ifdef __HUGS__
import Hugs.Prelude (MonadFix(mfix))
#endif
#if defined(__GLASGOW_HASKELL__)
import GHC.ST
#endif

#ifndef __HUGS__


















class (Monad m) => MonadFix m where
        
        
        
        
        mfix :: (a -> m a) -> m a
#endif /* !__HUGS__ */




instance MonadFix Maybe where
    mfix f = let a = f (unJust a) in a
             where unJust (Just x) = x
                   unJust Nothing  = error "mfix Maybe: Nothing"


instance MonadFix [] where
    mfix f = case fix (f . head) of
               []    -> []
               (x:_) -> x : mfix (tail . f)


instance MonadFix IO where
    mfix = fixIO 



instance MonadFix ((->) r) where
    mfix f = \ r -> let a = f a r in a

instance MonadFix (Either e) where
    mfix f = let a = f (unRight a) in a
             where unRight (Right x) = x
                   unRight (Left  _) = error "mfix Either: Left"

#if defined(__GLASGOW_HASKELL__)
instance MonadFix (ST s) where
        mfix = fixST
#endif


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4