packages feed

function-instances-algebra (empty) → 0.1

raw patch · 13 files changed

+243/−0 lines, 13 filesdep +basedep +numeric-preludesetup-changed

Dependencies added: base, numeric-prelude

Files

+ Data/Function/Instances/Algebra.hs view
@@ -0,0 +1,11 @@+-- | Import all Algebra.* instances.+module Data.Function.Instances.Algebra where++import Data.Function.Instances.Algebra.Absolute+import Data.Function.Instances.Algebra.Algebraic+import Data.Function.Instances.Algebra.Differential+import Data.Function.Instances.Algebra.Field+import Data.Function.Instances.Algebra.Lattice+import Data.Function.Instances.Algebra.Monoid+import Data.Function.Instances.Algebra.Ring+import Data.Function.Instances.Algebra.Transcendental
+ Data/Function/Instances/Algebra/Absolute.hs view
@@ -0,0 +1,9 @@+module Data.Function.Instances.Algebra.Absolute where++import Data.Function.Instances.Algebra.Ring++import Algebra.Absolute as A++instance C a => C (k -> a) where+  abs = (A.abs .)+  signum = (A.signum .)
+ Data/Function/Instances/Algebra/Algebraic.hs view
@@ -0,0 +1,11 @@+module Data.Function.Instances.Algebra.Algebraic where++import Data.Function.Instances.Algebra.Internal+import Data.Function.Instances.Algebra.Field++import Algebra.Algebraic as A++instance C a => C (k -> a) where+  sqrt = (A.sqrt .)+  root i = (A.root i .)+  f ^/ e = \x -> f x A.^/ e
+ Data/Function/Instances/Algebra/Differential.hs view
@@ -0,0 +1,13 @@+-- | Note: @'differentiate' f@ is not the derivative of+--   @f@. Rather, it is a function that takes one argument @x@+--   and returns the derivative of @f x@. In other words:+--+--   @ differentiate f = \\x -> differentiate (f x) @+module Data.Function.Instances.Algebra.Differential where++import Data.Function.Instances.Algebra.Ring++import Algebra.Differential as D++instance C a => C (k -> a) where+  differentiate = (D.differentiate .)
+ Data/Function/Instances/Algebra/Field.hs view
@@ -0,0 +1,12 @@+module Data.Function.Instances.Algebra.Field where++import Data.Function.Instances.Algebra.Internal+import Data.Function.Instances.Algebra.Ring++import Algebra.Field as F++instance C a => C (k -> a) where+  (/) = zipFn (F./)+  recip = (F.recip .)+  fromRational' = const . fromRational'+  f ^- e = \x -> f x F.^- e
+ Data/Function/Instances/Algebra/Internal.hs view
@@ -0,0 +1,4 @@+module Data.Function.Instances.Algebra.Internal where++zipFn :: (a -> b -> c) -> (d -> a) -> (d -> b) -> d -> c+zipFn op f g x = f x `op` g x
+ Data/Function/Instances/Algebra/Lattice.hs view
@@ -0,0 +1,8 @@+module Data.Function.Instances.Algebra.Lattice where++import Data.Function.Instances.Algebra.Internal+import Algebra.Lattice as L++instance C a => C ((->) k a) where+  up = zipFn up+  dn = zipFn dn
+ Data/Function/Instances/Algebra/Monoid.hs view
@@ -0,0 +1,9 @@+module Data.Function.Instances.Algebra.Monoid where++import Data.Function.Instances.Algebra.Internal+import Algebra.Monoid as M++instance C a => C (k -> a) where+  idt = const M.idt+  (<*>) = zipFn (M.<*>)+  cumulate fs = \x -> M.cumulate $ map ($ x) fs
+ Data/Function/Instances/Algebra/Ring.hs view
@@ -0,0 +1,10 @@+module Data.Function.Instances.Algebra.Ring where++import Data.Function.Instances.Algebra.Internal+import Algebra.Ring as R++instance C a => C (k -> a) where+  (*) = zipFn (R.*)+  one = const R.one+  fromInteger = const . R.fromInteger+  f ^ e = \x -> f x R.^ e
+ Data/Function/Instances/Algebra/Transcendental.hs view
@@ -0,0 +1,27 @@+module Data.Function.Instances.Algebra.Transcendental where++import Data.Function.Instances.Algebra.Internal+import Data.Function.Instances.Algebra.Algebraic++import Algebra.Transcendental as T++instance C a => C (k -> a) where+  pi = const T.pi+  exp = (T.exp .)+  log = (T.log .)+  logBase = zipFn T.logBase+  (**) = zipFn (T.**)+  sin = (T.sin .)+  tan = (T.tan .)+  cos = (T.cos .)+  asin = (T.asin .)+  atan = (T.atan .)+  acos = (T.acos .)+  sinh = (T.sinh .)+  tanh = (T.tanh .)+  cosh = (T.cosh .)+  asinh = (T.asinh .)+  atanh = (T.atanh .)+  acosh = (T.acosh .)+  +
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c)2012, Tobias Brandt++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 Tobias Brandt 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
+ function-instances-algebra.cabal view
@@ -0,0 +1,97 @@+-- function-instances-algebra.cabal auto-generated by cabal init. For+-- additional options, see+-- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.+-- The name of the package.+Name:                function-instances-algebra++-- The package version. See the Haskell package versioning policy+-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for+-- standards guiding when and how versions should be incremented.+Version:             0.1++-- A short (one-line) description of the package.+Synopsis:            Instances of the Algebra.* classes for functions++-- A longer description of the package.+Description: This package provides instances for functions @(k -> a)@ of the classes    +  Absolute, Algebraic, Differential, Field, Lattice, Monoid, Ring and Transcendental+  from the numeric-prelude package. An instance for Additive already comes with the+  original package.+  .+  If @a@ has an instance for one of the classes, then @(k -> a)@ has too. +  The instances do what you would expect. Values become constant functions:+  .+  @+    zero = const zero+  @+  .+  Unary functions are composed:+  .+  @+    sin f = sin . f+  @+  .+  Binary functions fan out the input and combine both results:+  .+  @+    f + g = \\x -> f x + g x+  @+  .+  You can either import them separately or import @Data.Function.Instances.Algebra@ to+  get them all at once.++-- URL for the project homepage or repository.+Homepage:            github.com/kreuzschlitzschraubenzieher/function-instances-algebra++-- The license under which the package is released.+License:             BSD3++-- The file containing the license text.+License-file:        LICENSE++-- The package author(s).+Author:              Tobias Brandt++-- An email address to which users can send suggestions, bug reports,+-- and patches.+Maintainer:          tob.brandt@gmail.com++-- A copyright notice.+-- Copyright:           ++Category:            Math++Build-type:          Simple++-- Extra files to be distributed with the package, such as examples or+-- a README.+-- Extra-source-files:  ++-- Constraint on the version of Cabal needed to build this package.+Cabal-version:       >=1.6+++Library+  -- Modules exported by the library.+  Exposed-modules:+    Data.Function.Instances.Algebra+    Data.Function.Instances.Algebra.Absolute+    Data.Function.Instances.Algebra.Algebraic+    Data.Function.Instances.Algebra.Differential+    Data.Function.Instances.Algebra.Field+    Data.Function.Instances.Algebra.Lattice+    Data.Function.Instances.Algebra.Monoid+    Data.Function.Instances.Algebra.Ring+    Data.Function.Instances.Algebra.Transcendental+  +  -- Packages needed in order to build this package.+  Build-depends:+    base ==4.*, numeric-prelude ==0.3.*+  +  -- Modules not exported by this package.+  Other-modules:   +    Data.Function.Instances.Algebra.Internal+  +  -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.+  -- Build-tools:         +