[added some new library modules, Data.Function Control.Monad.Fix Control.Monad.Instances
John Meacham <john@repetae.net>**20090226105827
 Ignore-this: 3514a682094e7c96412aa0233d22bb9c
] adddir ./lib/base/Control/Monad
addfile ./lib/base/Control/Monad/Fix.hs
hunk ./lib/base/Control/Monad/Fix.hs 1
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Control.Monad.Fix
+-- Copyright   :  (c) Andy Gill 2001,
+--                (c) Oregon Graduate Institute of Science and Technology, 2002
+-- License     :  BSD-style (see the file libraries/base/LICENSE)
+-- Maintainer  :  libraries@haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Monadic fixpoints.
+--
+-- For a detailed discussion, see Levent Erkok's thesis,
+-- /Value Recursion in Monadic Computations/, Oregon Graduate Institute, 2002.
+--
+-----------------------------------------------------------------------------
+
+module Control.Monad.Fix (
+        MonadFix(
+           mfix -- :: (a -> m a) -> m a
+         ),
+        fix     -- :: (a -> a) -> a
+  ) where
+
+import Prelude
+import System.IO
+import Control.Monad.Instances ()
+import Data.Function (fix)
+
+-- | Monads having fixed points with a \'knot-tying\' semantics.
+-- Instances of 'MonadFix' should satisfy the following laws:
+--
+-- [/purity/]
+--      @'mfix' ('return' . h)  =  'return' ('fix' h)@
+--
+-- [/left shrinking/ (or /tightening/)]
+--      @'mfix' (\\x -> a >>= \\y -> f x y)  =  a >>= \\y -> 'mfix' (\\x -> f x y)@
+--
+-- [/sliding/]
+--      @'mfix' ('Control.Monad.liftM' h . f)  =  'Control.Monad.liftM' h ('mfix' (f . h))@,
+--      for strict @h@.
+--
+-- [/nesting/]
+--      @'mfix' (\\x -> 'mfix' (\\y -> f x y))  =  'mfix' (\\x -> f x x)@
+--
+-- This class is used in the translation of the recursive @do@ notation
+-- supported by GHC and Hugs.
+class (Monad m) => MonadFix m where
+        -- | The fixed point of a monadic computation.
+        -- @'mfix' f@ executes the action @f@ only once, with the eventual
+        -- output fed back as the input.  Hence @f@ should not be strict,
+        -- for then @'mfix' f@ would diverge.
+        mfix :: (a -> m a) -> m a
+
+-- Instances of MonadFix for Prelude monads
+
+-- Maybe:
+instance MonadFix Maybe where
+    mfix f = let a = f (unJust a) in a
+             where unJust (Just x) = x
+
+-- List:
+instance MonadFix [] where
+    mfix f = case fix (f . head) of
+               []    -> []
+               (x:_) -> x : mfix (tail . f)
+
+-- IO:
+instance MonadFix IO where
+    mfix = fixIO 
+
+instance MonadFix ((->) r) where
+    mfix f = \ r -> let a = f a r in a
addfile ./lib/base/Control/Monad/Instances.hs
hunk ./lib/base/Control/Monad/Instances.hs 1
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Control.Monad.Instances
+-- Copyright   :  (c) The University of Glasgow 2001
+-- License     :  BSD-style (see the file libraries/base/LICENSE)
+--
+-- Maintainer  :  libraries@haskell.org
+-- Stability   :  provisional
+-- Portability :  portable
+--
+-- 'Functor' and 'Monad' instances for @(->) r@ and
+-- 'Functor' instances for @(,) a@ and @'Either' a@.
+
+module Control.Monad.Instances (Functor(..),Monad(..)) where
+
+import Prelude
+
+instance Functor ((->) r) where
+        fmap = (.)
+
+instance Monad ((->) r) where
+        return = const
+        f >>= k = \ r -> k (f r) r
+
+instance Functor ((,) a) where
+        fmap f (x,y) = (x, f y)
+
+instance Functor (Either a) where
+        fmap _ (Left x) = Left x
+        fmap f (Right y) = Right (f y)
addfile ./lib/base/Data/Function.hs
hunk ./lib/base/Data/Function.hs 1
+{-# OPTIONS_JHC -N #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Data.Function
+-- Copyright   :  Nils Anders Danielsson 2006
+-- License     :  BSD-style (see the LICENSE file in the distribution)
+--
+-- Maintainer  :  libraries@haskell.org
+-- Stability   :  experimental
+-- Portability :  portable
+--
+-- Simple combinators working solely on and with functions.
+
+module Data.Function
+  ( -- * "Prelude" re-exports
+    id, const, (.), flip, ($)
+    -- * Other combinators
+  , fix
+  , on
+  ) where
+
+import Jhc.Basics
+
+infixl 0 `on`
+
+-- | @'fix' f@ is the least fixed point of the function @f@,
+-- i.e. the least defined @x@ such that @f x = x@.
+fix :: (a -> a) -> a
+fix f = let x = f x in x
+
+-- | @(*) \`on\` f = \\x y -> f x * f y@.
+--
+-- Typical usage: @'Data.List.sortBy' ('compare' \`on\` 'fst')@.
+--
+-- Algebraic properties:
+--
+-- * @(*) \`on\` 'id' = (*)@ (if @(*) &#x2209; {&#x22a5;, 'const' &#x22a5;}@)
+--
+-- * @((*) \`on\` f) \`on\` g = (*) \`on\` (f . g)@
+--
+-- * @'flip' on f . 'flip' on g = 'flip' on (g . f)@
+
+-- Proofs (so that I don't have to edit the test-suite):
+
+--   (*) `on` id
+-- =
+--   \x y -> id x * id y
+-- =
+--   \x y -> x * y
+-- = { If (*) /= _|_ or const _|_. }
+--   (*)
+
+--   (*) `on` f `on` g
+-- =
+--   ((*) `on` f) `on` g
+-- =
+--   \x y -> ((*) `on` f) (g x) (g y)
+-- =
+--   \x y -> (\x y -> f x * f y) (g x) (g y)
+-- =
+--   \x y -> f (g x) * f (g y)
+-- =
+--   \x y -> (f . g) x * (f . g) y
+-- =
+--   (*) `on` (f . g)
+-- =
+--   (*) `on` f . g
+
+--   flip on f . flip on g
+-- =
+--   (\h (*) -> (*) `on` h) f . (\h (*) -> (*) `on` h) g
+-- =
+--   (\(*) -> (*) `on` f) . (\(*) -> (*) `on` g)
+-- =
+--   \(*) -> (*) `on` g `on` f
+-- = { See above. }
+--   \(*) -> (*) `on` g . f
+-- =
+--   (\h (*) -> (*) `on` h) (g . f)
+-- =
+--   flip on (g . f)
+
+on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
+(*) `on` f = \x y -> f x * f y
hunk ./lib/base/Data/Typeable.hs 5
+import Maybe
+import Jhc.Prim
+
+
hunk ./lib/base/Data/Typeable.hs 11
-instance Eq TypeRep where
-    (==) = primTypeRepEq
+--instance Eq TypeRep where
+--    (==) = primTypeRepEq
hunk ./lib/base/Data/Typeable.hs 31
+unsafeCoerce = unsafeCoerce__
+