composition 1.0.1.1 → 1.0.2
raw patch · 4 files changed
+204/−177 lines, 4 filessetup-changedPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- LICENSE +30/−30
- Setup.hs +2/−2
- composition.cabal +23/−21
- src/Data/Composition.hs +149/−124
LICENSE view
@@ -1,30 +1,30 @@-Copyright (c) 2011-2012, Dan Burton - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Dan Burton nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2011-2012, Dan Burton++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Dan Burton nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Setup.hs view
@@ -1,2 +1,2 @@-import Distribution.Simple -main = defaultMain +import Distribution.Simple+main = defaultMain
composition.cabal view
@@ -1,21 +1,23 @@-name: composition -version: 1.0.1.1 -synopsis: Combinators for unorthodox function composition - -license: BSD3 -license-file: LICENSE -author: Dan Burton -maintainer: danburton.email@gmail.com - -category: Data -build-type: Simple -cabal-version: >=1.8 - -library - hs-source-dirs: src - exposed-modules: Data.Composition - extensions: NoImplicitPrelude - -source-repository head - type: git - location: git://github.com/DanBurton/composition.git +name: composition+version: 1.0.2+synopsis: Combinators for unorthodox function composition++license: BSD3+license-file: LICENSE+author: Dan Burton+maintainer: danburton.email@gmail.com+bug-reports:+ https://github.com/DanBurton/composition/issues++category: Data+build-type: Simple+cabal-version: >=1.8++library+ hs-source-dirs: src+ exposed-modules: Data.Composition+ extensions: NoImplicitPrelude++source-repository head+ type: git+ location: git://github.com/DanBurton/composition.git
src/Data/Composition.hs view
@@ -1,124 +1,149 @@--- | This module is for convenience and demonstrative purposes --- more than it is for providing actual value. --- I do not recommend that you rely on this module --- for performance-sensitive code. --- Because this module is not based on Prelude's (.), --- some chances at optimization might be missed by your compiler. -module Data.Composition ( - -- * Math - (∘) - - -- * Colons and dots - , (.:) - , (.:.) - , (.::) - , (.::.) - , (.:::) - , (.:::.) - , (.::::) - , (.::::.) - - -- * Asterisks - , (.*) - , (.**) - , (.***) - , (.****) - , (.*****) - , (.******) - , (.*******) - , (.********) - - -- * composeN - , compose1 - , compose2 - , compose3 - , compose4 - , compose5 - , compose6 - , compose7 - , compose8 - , compose9 - - ) where - --- Not exported. This is defined here to remove the dependency on base -(.) :: (b -> c) -> (a -> b) -> a -> c -(f . g) x = f (g x) - --- | The mathematical symbol for function composition. -(∘) :: (b -> c) -> (a -> b) -> a -> c -(∘) = (.) - --- | 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@. --- --- This function is defined as --- --- > (f .: g) x y = f (g x y) --- --- 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) - --- | Equivalent to '.:' --- --- The pattern of appending asterisks is --- 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 -(.*) = (.) . (.) - -(.**) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e -(.**) = (.) . (.*) - -(.***) = (.) . (.**) -(.****) = (.) . (.***) -(.*****) = (.) . (.****) -(.******) = (.) . (.*****) -(.*******) = (.) . (.******) -(.********) = (.) . (.*******) - --- | @composeN f g@ means give @g@ @N@ inputs --- and then pass its result to @f@. -compose1 :: (b -> c) -> (a -> b) -> a -> c -compose1 = (.) - -compose2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d -compose2 = (.*) - -compose3 :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e -compose3 = (.**) - -compose4 = (.***) -compose5 = (.****) -compose6 = (.*****) -compose7 = (.******) -compose8 = (.*******) -compose9 = (.********) - --- | One compact pattern for composition operators is to --- "count the dots after the first one", --- which begins with the common '.:', and proceeds by first --- appending another @.@ and then replacing it with @:@ -(.:.) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e -(.:.) = (.**) - -(.::) = (.***) -(.::.) = (.****) -(.:::) = (.*****) -(.:::.) = (.******) -(.::::) = (.*******) -(.::::.) = (.********) +-- | This module is for convenience and demonstrative purposes+-- more than it is for providing actual value.+-- I do not recommend that you rely on this module+-- for performance-sensitive code.+-- Because this module is not based on Prelude's (.),+-- some chances at optimization might be missed by your compiler.+module Data.Composition (+ -- * Math+ (∘)++ -- * Colons and dots+ , (.:)+ , (.:.)+ , (.::)+ , (.::.)+ , (.:::)+ , (.:::.)+ , (.::::)+ , (.::::.)++ -- * Asterisks+ , (.*)+ , (.**)+ , (.***)+ , (.****)+ , (.*****)+ , (.******)+ , (.*******)+ , (.********)++ -- * composeN+ , compose1+ , compose2+ , compose3+ , compose4+ , compose5+ , compose6+ , compose7+ , compose8+ , compose9++ ) where++-- Not exported. This is defined here to remove the dependency on base+(.) :: (b -> c) -> (a -> b) -> a -> c+(f . g) x = f (g x)++infixr 9 .++-- | The mathematical symbol for function composition.+(∘) :: (b -> c) -> (a -> b) -> a -> c+(∘) = (.)++infixr 9 ∘++-- | 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@.+--+-- This function is defined as+--+-- > (f .: g) x y = f (g x y)+--+-- 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)++infixr 8 .:++-- | Equivalent to '.:'+--+-- The pattern of appending asterisks is+-- 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+(.*) = (.) . (.)++infixr 8 .*++(.**) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e+(.**) = (.) . (.*)++(.***) = (.) . (.**)+(.****) = (.) . (.***)+(.*****) = (.) . (.****)+(.******) = (.) . (.*****)+(.*******) = (.) . (.******)+(.********) = (.) . (.*******)++infixr 8 .**+infixr 8 .***+infixr 8 .****+infixr 8 .*****+infixr 8 .******+infixr 8 .*******+infixr 8 .********+++-- | @composeN f g@ means give @g@ @N@ inputs+-- and then pass its result to @f@.+compose1 :: (b -> c) -> (a -> b) -> a -> c+compose1 = (.)++compose2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d+compose2 = (.*)++compose3 :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e+compose3 = (.**)++compose4 = (.***)+compose5 = (.****)+compose6 = (.*****)+compose7 = (.******)+compose8 = (.*******)+compose9 = (.********)++-- | One compact pattern for composition operators is to+-- "count the dots after the first one",+-- which begins with the common '.:', and proceeds by first+-- appending another @.@ and then replacing it with @:@+(.:.) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e+(.:.) = (.**)++(.::) = (.***)+(.::.) = (.****)+(.:::) = (.*****)+(.:::.) = (.******)+(.::::) = (.*******)+(.::::.) = (.********)++infixr 8 .:.+infixr 8 .::+infixr 8 .::.+infixr 8 .:::+infixr 8 .:::.+infixr 8 .::::+infixr 8 .::::.