Mon Jun 29 12:34:36 BST 2009 Ross Paterson
* make some Applicative functions into methods, and split off Data.Functor
The following functions
(<$) :: Functor f => a > f b > f a
(*>) :: Applicative f => f a > f b > f b
(<*) :: Applicative f => f a > f b > f a
some :: Alternative f => f a > f [a]
many :: Alternative f => f a > f [a]
are moved into the corresponding classes, with the existing implementations
as default definitions. This gives people creating instances the option of
defining specialized implementations of these functions, though they should
be equivalent to the default definitions.
Although (<$) is now a method of the Functor class, it is hidden in the
reexport by the Prelude, Control.Monad and Monad. The new module
Data.Functor exposes the full class, plus the function (<$>). These are
also reexported by Control.Applicative.
New patches:
[make some Applicative functions into methods, and split off Data.Functor
Ross Paterson **20090629113436
Ignorethis: f9525a9ed3e44ec844448abafe32e15e
The following functions
(<$) :: Functor f => a > f b > f a
(*>) :: Applicative f => f a > f b > f b
(<*) :: Applicative f => f a > f b > f a
some :: Alternative f => f a > f [a]
many :: Alternative f => f a > f [a]
are moved into the corresponding classes, with the existing implementations
as default definitions. This gives people creating instances the option of
defining specialized implementations of these functions, though they should
be equivalent to the default definitions.
Although (<$) is now a method of the Functor class, it is hidden in the
reexport by the Prelude, Control.Monad and Monad. The new module
Data.Functor exposes the full class, plus the function (<$>). These are
also reexported by Control.Applicative.
] {
addfile ./Data/Functor.hs
hunk ./Control/Applicative.hs 33
 * Instances
Const(..), WrappedMonad(..), WrappedArrow(..), ZipList(..),
 * Utility functions
 (<$>), (<$), (*>), (<*), (<**>),
+ (<$>), (<$), (<**>),
liftA, liftA2, liftA3,
hunk ./Control/Applicative.hs 35
 optional, some, many
+ optional,
) where
import Prelude hiding (id,(.))
hunk ./Control/Applicative.hs 46
(Arrow(arr, (&&&)), ArrowZero(zeroArrow), ArrowPlus((<+>)))
import Control.Monad (liftM, ap, MonadPlus(..))
import Control.Monad.Instances ()
+import Data.Functor ((<$>), (<$))
import Data.Monoid (Monoid(..))
infixl 3 <>
hunk ./Control/Applicative.hs 50
infixl 4 <$>, <$
infixl 4 <*>, <*, *>, <**>
  A functor with application.
hunk ./Control/Applicative.hs 68
 [/interchange/]
 @u '<*>' 'pure' y = 'pure' ('$' y) '<*>' u@

+ [/ignore left value/]
+ @u '*>' v = 'pure' ('const' 'id') '<*>' u '<*>' v@
+
+ [/ignore right value/]
+ @u '<*' v = 'pure' 'const' '<*>' u '<*>' v@
+
 The 'Functor' instance should satisfy

 @
hunk ./Control/Applicative.hs 81
 @

 If @f@ is also a 'Monad', define @'pure' = 'return'@ and @('<*>') = 'ap'@.
+
+ Minimal complete definition: 'pure' and '<*>'.
class Functor f => Applicative f where
  Lift a value.
hunk ./Control/Applicative.hs 91
  Sequential application.
(<*>) :: f (a > b) > f a > f b
+   Sequence actions, discarding the value of the first argument.
+ (*>) :: f a > f b > f b
+ (*>) = liftA2 (const id)
+
+   Sequence actions, discarding the value of the second argument.
+ (<*) :: f a > f b > f a
+ (<*) = liftA2 const
+
  A monoid on applicative functors.
hunk ./Control/Applicative.hs 100
+
+ Minimal complete definition: 'empty' and '<>'.
+
+ 'some' and 'many' should be the least solutions of the equations:
+
+ * @some v = (:) '<$>' v '<*>' many v@
+
+ * @many v = some v '<>' 'pure' []@
class Applicative f => Alternative f where
  The identity of '<>'
empty :: f a
hunk ./Control/Applicative.hs 114
  An associative binary operation
(<>) :: f a > f a > f a
+   One or more.
+ some :: f a > f [a]
+ some v = some_v
+ where many_v = some_v <> pure []
+ some_v = (:) <$> v <*> many_v
+
+   Zero or more.
+ many :: f a > f [a]
+ many v = many_v
+ where many_v = some_v <> pure []
+ some_v = (:) <$> v <*> many_v
+
 instances for Prelude types
instance Applicative Maybe where
hunk ./Control/Applicative.hs 209
 extra functions
  A synonym for 'fmap'.
(<$>) :: Functor f => (a > b) > f a > f b
f <$> a = fmap f a

  Replace the value.
(<$) :: Functor f => a > f b > f a
(<$) = (<$>) . const

  Sequence actions, discarding the value of the first argument.
(*>) :: Applicative f => f a > f b > f b
(*>) = liftA2 (const id)

  Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a > f b > f a
(<*) = liftA2 const

  A variant of '<*>' with the arguments reversed.
(<**>) :: Applicative f => f a > f (a > b) > f b
(<**>) = liftA2 (flip ($))
hunk ./Control/Applicative.hs 229
  One or none.
optional :: Alternative f => f a > f (Maybe a)
optional v = Just <$> v <> pure Nothing

  One or more.
some :: Alternative f => f a > f [a]
some v = some_v
 where many_v = some_v <> pure []
 some_v = (:) <$> v <*> many_v

  Zero or more.
many :: Alternative f => f a > f [a]
many v = many_v
 where many_v = some_v <> pure []
 some_v = (:) <$> v <*> many_v
hunk ./Data/Functor.hs 1
+
+ 
+ Module : Data.Functor
+ Copyright : (c) The University of Glasgow 2001
+ License : BSDstyle (see the file libraries/base/LICENSE)
+
+ Maintainer : libraries@haskell.org
+ Stability : provisional
+ Portability : portable
+
+ Functors: uniform action over a parameterized type, generalizing the
+ 'map' function on lists.
+
+module Data.Functor
+ (
+ Functor(fmap, (<$)),
+ (<$>),
+ ) where
+
+#ifdef __GLASGOW_HASKELL__
+import GHC.Base (Functor(..))
+#endif
+
+infixl 4 <$>
+
+  An infix synonym for 'fmap'.
+(<$>) :: Functor f => (a > b) > f a > f b
+(<$>) = fmap
hunk ./GHC/Base.lhs 114
infixr 9 .
infixr 5 ++
+infixl 4 <$
infixl 1 >>, >>=
infixr 0 $
hunk ./GHC/Base.lhs 178
class Functor f where
fmap :: (a > b) > f a > f b
+   Replace all locations in the input with the same value.
+  The default definition is @'fmap' . 'const'@, but this may be
+  overridden with a more efficient version.
+ (<$) :: a > f b > f a
+ (<$) = fmap . const
+
{  The 'Monad' class defines the basic operations over a /monad/,
a concept from a branch of mathematics known as /category theory/.
From the perspective of a Haskell programmer, however, it is best to
hunk ./base.cabal 127
Data.Fixed,
Data.Foldable
Data.Function,
+ Data.Functor,
Data.HashTable,
Data.IORef,
Data.Int,
}
Context:
[TAG 20090625
Ian Lynagh **20090625160056]
Patch bundle hash:
d7d9bd4f8b5727799df364649de0acf0a027d0a8