concatenative (empty) → 0.0.0
raw patch · 4 files changed
+103/−0 lines, 4 filesdep +basesetup-changed
Dependencies added: base
Files
- Control/Concatenative.hs +61/−0
- LICENSE +20/−0
- Setup.lhs +3/−0
- concatenative.cabal +19/−0
+ Control/Concatenative.hs view
@@ -0,0 +1,61 @@+{-| Control.Concatenative brings postfix notation in the style of factor+ (see http://factorcode.org) to haskell. Interfaces using both+ combinators and arrows are available. +-}+module Control.Concatenative (+ -- * Postfix combinators+ bi, tri, biSp, triSp, biAp, triAp, ifte,+ -- * Postfix arrows + (>>@), dup, swap, both,+ (>>>), (&&&), (***), first, second+ ) where+import Control.Arrow++-- Function Interface++-- |Apply both arguments to a and combine the results+bi :: (a -> b) -> (a -> c) -> (b -> c -> d) -> a -> d+bi f g c = \x-> c (f x) (g x)++-- |Apply each of three arguments to a and combine the results+tri :: (a -> b) -> (a -> c) -> (a -> d) -> (b -> c -> d -> e) -> a -> e+tri f g h c = \x-> c (f x) (g x) (h x)++-- |Apply the first argument to a, the second to b, and combine the results+biSp :: (a -> c) -> (b -> d) -> (c -> d -> e) -> a -> b -> e+biSp f g c = \x y-> c (f x) (g y)++-- |Apply the first argument to a, the second to b, and the third to c, combining the results+triSp :: (a -> d) -> (b -> e) -> (c -> f) -> (d -> e -> f -> g) -> a -> b -> c -> g+triSp f g h c = \x y z-> c (f x) (g y) (h z)++-- |Apply a function to two values and combine the results+biAp :: (t -> t1) -> (t1 -> t1 -> t2) -> t -> t -> t2+biAp f c = \x y-> c (f x) (f y)++-- |Apply a function to three values and combine the results+triAp :: (a -> b) -> (b -> b -> b -> c) -> a -> a -> a -> c+triAp f c = \x y z-> c (f x) (f y) (f z)++ifte :: (a -> Bool) -- ^ A predicate+ -> (a -> b) -- ^ Applied if the predicate yields True+ -> (a -> b) -- ^ Applied if the predicate yields False+ -> a -> b+ifte test ca cb = \x ->+ if test x then ca x else cb x++-- Arrow Interface++-- |Combine with a binary function+(>>@) :: Arrow a => a b (x,y) -> (x -> y -> z) -> a b z+a >>@ f = a >>> arr (\(x,y) -> f x y)++-- |Arrow version of biAp+both :: Arrow a => a b c -> a (b,b) (c,c)+both a = first a >>> second a++dup :: Arrow a => a b (b,b)+dup = arr (\x-> (x,x))++swap :: Arrow a => a (x,y) (y,x)+swap = arr (\(x,y) -> (y,x))
+ LICENSE view
@@ -0,0 +1,20 @@+Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice,+ this list of conditions and the following disclaimer.++2. 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.++THIS SOFTWARE IS PROVIDED ``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+DEVELOPERS AND 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.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ concatenative.cabal view
@@ -0,0 +1,19 @@+name: concatenative+version: 0.0.0+synopsis: A library for postfix control flow.+description: Concatenative gives haskell factor style+ combinators and arrows for postfix notation.+ For more information on stack based languages,+ see <http://concatenative.org>+category: Control+license: BSD3+license-file: LICENSE+author: Sam Anklesaria+maintainer: amsay@amsay.net+build-depends: base >= 3 && < 5+build-type: Simple+Cabal-Version: >= 1.2++Library+ exposed-modules: Control.Concatenative+ Build-Depends: base >= 3 && < 5