packages feed

data-function-meld 0.1.0.0 → 0.1.1.0

raw patch · 2 files changed

+48/−15 lines, 2 filesdep ~base

Dependency ranges changed: base

Files

data-function-meld.cabal view
@@ -1,5 +1,5 @@ name:                data-function-meld
-version:             0.1.0.0
+version:             0.1.1.0
 synopsis:            Map the arguments and return value of functions.
 description:         Map the arguments and return value of functions.   
 homepage:            https://github.com/erisco/data-function-meld
@@ -16,8 +16,17 @@ 
   exposed-modules:     Data.Function.Meld
   
-  build-depends:       base >=4.7 && <4.8
+  build-depends:       base >=4.0 && <999
   
   hs-source-dirs:      src
   
   default-language:    Haskell2010
+
+source-repository head
+  type:     git
+  location: https://github.com/erisco/data-function-meld
+
+source-repository this
+  type:     git
+  location: https://github.com/erisco/data-function-meld
+  tag:      v0.1.1.0
src/Data/Function/Meld.hs view
@@ -1,8 +1,8 @@-{-| Map the arguments and return value of functions. +{-| Map the arguments and return value of functions.   General use: -  - @f $* g1 $$ g2 … $$ gn *$ h = \x1 … xn -> h (f (g1 x1) (g2 x2) … (gn xn))@+  - @f $* g1 $$ g2 … $$ gn *$ h = \\x1 … xn -> h (f (g1 x1) (g2 x2) … (gn xn))@  Examples: @@ -10,7 +10,22 @@   - @comparing f = compare $* f $$ f *$ id@   - @f . g = f $* g *$ id@ -Work based on <http://conal.net/blog/posts/semantic-editor-combinators Semantic Editor Combinators> (Conal Elliot, 2016/05/19).+Related work:++  - <http://conal.net/blog/posts/semantic-editor-combinators Semantic Editor Combinators> +    (Conal Elliott, 2008\/11\/24). Introduces composable editors for +    function arguments and return values.+  - <http://matt.immute.net/content/pointless-fun Pointless Fun> (Matt +    Hellige, 2008\/12\/03). Derives a similar operator named @~>@. This+    operator composes an editor which can then be applied to the subject+    to edit. This better agrees with Conal's concept of Semantic Editor +    Combinators. In contrast, @$*@ includes the subject as part of the +    editor, though you can write @($* g1 $$ g2 … $$ gn *$ h)@ for an +    editor independent of the subject. Also, @~>@ is right-associative +    whereas @$*@ and @$$@ are left-associative.+  - <http://hackage.haskell.org/package/TypeCompose-0.9.11/docs/Control-Compose.html TypeCompose version 0.9.11>+    (Conal Elliott, 2016\/01\/15). Package including an implementation of+    @~>@. -} module Data.Function.Meld ( ($*)@@ -18,33 +33,42 @@ , (*$) ) where -import Prelude (flip, (.), ($))+import Prelude (flip)+import Control.Category (Category, (.), id)  -- | Map a function argument.-arg :: (a' -> a) -> (a -> b) -> a' -> b+arg :: Category cat => cat a' a -> cat a b -> cat a' b arg = flip (.)  -- | Map a function return value.-ret :: (b -> c) -> (a -> b) -> a -> c+ret :: Category cat => cat b c -> cat a b -> cat a c ret = (.)  -- | Begin melding. ----- @f $* g1 $$ g2 … $$ gn *$ h = \x1 … xn -> h (f (g1 x1) (g2 x2) … (gn xn))@-($*) :: (b -> c) -> (a -> b) -> (c -> d) -> a -> d+-- @f $* g1 $$ g2 … $$ gn *$ h = \\x1 … xn -> h (f (g1 x1) (g2 x2) … (gn xn))@+($*) :: Category cat =>+           cat b c+        -> cat a b+        -> cat c d+        -> cat a d ($*) x f g = ret g (arg f x) infixl 8 $*  -- | Continue melding. ----- @f $* g1 $$ g2 … $$ gn *$ h = \x1 … xn -> h (f (g1 x1) (g2 x2) … (gn xn))@-($$) :: (((b -> c) -> a -> d) -> e) -> (a -> b) -> (c -> d) -> e+-- @f $* g1 $$ g2 … $$ gn *$ h = \\x1 … xn -> h (f (g1 x1) (g2 x2) … (gn xn))@+($$) :: Category cat =>+           ((cat b c -> cat a d) -> e)+        -> cat a b +        -> cat c d+        -> e ($$) f g h = f (ret h . arg g) infixl 7 $$  -- | Finish melding. ----- @f $* g1 $$ g2 … $$ gn *$ h = \x1 … xn -> h (f (g1 x1) (g2 x2) … (gn xn))@-(*$) :: (a -> b) -> a -> b-(*$) = ($)+-- @f $* g1 $$ g2 … $$ gn *$ h = \\x1 … xn -> h (f (g1 x1) (g2 x2) … (gn xn))@+(*$) :: Category cat => cat a b -> cat a b+(*$) = id infixl 6 *$