composition 1.0.0.0 → 1.0.0.1
raw patch · 2 files changed
+26/−13 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- composition.cabal +2/−2
- src/Data/Composition.hs +24/−11
composition.cabal view
@@ -1,5 +1,5 @@ name: composition -version: 1.0.0.0 +version: 1.0.0.1 synopsis: Combinators for unorthodox function composition license: BSD3 @@ -24,4 +24,4 @@ source-repository this type: darcs location: http://patch-tag.com/r/DanBurton/composition - tag: composition-1.0.0.0 + tag: composition-1.0.0.1
src/Data/Composition.hs view
@@ -20,24 +20,37 @@ -- Not exported. This is defined here to remove the dependency on base (.) :: (b -> c) -> (a -> b) -> a -> c -(.) f g x = f (g x) +(f . g) x = f (g x) --- | This function is defined as +-- | Compose two functions. @f .: g@ is similar to @f . g@ +-- except that @g@ will be fed /two/ arguments instead of one +-- before handing its result to @f@. -- --- > (.:) f g x y = f (g x y) +-- This function is defined as -- --- Example usage: @bind = join .: flip fmap@ --- Notice how two arguments will be given to @flip fmap@ before the result --- is passed to @join@. +-- > (f .: g) x y = f (g x y) -- --- This is equivalent to @bind v f = join (fmap v f)@ +-- Example usage: +-- +-- > concatMap :: (a -> b) -> [a] -> [b] +-- > concatMap = concat .: map +-- +-- Notice how /two/ arguments +-- (the function /and/ the list) +-- will be given to @map@ before the result +-- is passed to @concat@. This is equivalent to: +-- +-- > concatMap f xs = concat (map f xs) (.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d -(.:) f g x y = f (g x y) +(f .: g) x y = f (g x y) --- | Equivalent to '(.:)' +-- | Equivalent to '.:' -- --- The pattern of appending asterisks is more extensible, --- but uncommon in practice. +-- The pattern of appending asterisks is +-- more straightforward to extend to similar functions: +-- (compose2 = .*, compose3 = .**, etc). +-- However, @.:@ has been commonly adopted amongst Haskellers, +-- and the need for compose3 and beyond is rare in practice. (.*) :: (c -> d) -> (a -> b -> c) -> a -> b -> d (.*) = (.) . (.)