packages feed

control-dotdotdot (empty) → 0.1.0.0

raw patch · 5 files changed

+151/−0 lines, 5 filesdep +basesetup-changed

Dependencies added: base

Files

+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for control-dotdotdot
+
+## 0.1.0.0  -- YYYY-mm-dd
+
+* First version. Released on an unsuspecting world.
+ Control/DotDotDot.hs view
@@ -0,0 +1,71 @@+-- | Haskell operator @g ... f = \x1 .. xn -> g (f x1 .. xn)@. Compose+-- functions such that all arguments are applied. Obviates @(.).(.)@ and+-- similar patterns in some cases.+--+-- Examples:+--+-- @+-- > ((+) ... (+) ... (+)) (1 :: Int) 2 3 4+-- 10+-- @+--+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-}++module Control.DotDotDot+( DotDotDot((...))+, (…)+, IsFun+, Return+, Replace+)+where++import Data.Bool+  ( Bool(True, False)+  )+--++import Prelude ()++-- | @IsFun f@ is @'True@ if @f@ has form @_ -> _@ and @'False@ otherwise.+--+type family IsFun (a :: *) :: Bool where+  IsFun (_ -> _) = 'True+  IsFun _        = 'False+--++-- | Class for defining '...' recursively on function types.+--+class b ~ IsFun f => DotDotDot f (b :: Bool) where+  type Return (f :: *) (b :: Bool) :: *+  type Replace (f :: *) (r :: *) (b :: Bool) :: *+  (...) :: (Return f b -> r) -> f -> Replace f r b+  infixr 9 ...+--++instance DotDotDot b (IsFun b) => DotDotDot (a -> b) 'True where+  type Return (_ -> b) 'True = Return b (IsFun b)+  type Replace (a -> b) r 'True = a -> Replace b r (IsFun b)+  (...) g f x = g ... f x+--++instance 'False ~ IsFun a => DotDotDot a 'False where+  type Return a 'False = a+  type Replace _ r 'False = r+  (...) f x = f x+--++-- | Alias for '...'.+--+(…) ::+  (b ~ IsFun f, DotDotDot f b) =>+  (Return f b -> r) -> f -> Replace f r b+(…) = (...)+infixr 9 …++
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2017, Eric Brisco
+
+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 Eric Brisco 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
@@ -0,0 +1,2 @@+import Distribution.Simple
+main = defaultMain
+ control-dotdotdot.cabal view
@@ -0,0 +1,43 @@+-- Initial control-dotdotdot.cabal generated by cabal init.  For further 
+-- documentation, see http://haskell.org/cabal/users-guide/
+
+name:                control-dotdotdot
+version:             0.1.0.0
+synopsis:            Haskell operator
+                     `g ... f = \x1 .. xn -> g (f x1 .. xn)`.
+description:         Haskell operator
+                     `g ... f = \x1 .. xn -> g (f x1 .. xn)`.
+                     Compose functions such that all arguments are
+                     applied. Obviates `(.).(.)` and similar patterns in
+                     some cases.
+homepage:            https://github.com/erisco/control-dotdotdot
+license:             BSD3
+license-file:        LICENSE
+author:              Eric Brisco
+maintainer:          eric.brisco@gmail.com
+category:            Control
+build-type:          Simple
+extra-source-files:  ChangeLog.md
+cabal-version:       >=1.10
+
+
+source-repository this
+  type:         git
+  location:     http://github.com/erisco/control-dotdotdot.git
+  tag:          0.1.0.0
+
+  
+library
+  
+  exposed-modules:     Control.DotDotDot
+  
+  other-extensions:    DataKinds
+                       FlexibleContexts
+                       FlexibleInstances
+                       MultiParamTypeClasses
+                       TypeFamilies
+                       UndecidableInstances
+  
+  build-depends:       base >=4.9 && <4.10
+  
+  default-language:    Haskell2010