packages feed

applicative-numbers 0.0.9 → 0.1.2

raw patch · 6 files changed

+147/−22 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

− Makefile
@@ -1,1 +0,0 @@-include ../cho-home-cabal-make.inc
applicative-numbers.cabal view
@@ -1,5 +1,5 @@ name:                applicative-numbers-version:             0.0.9+version:             0.1.2 cabal-version:       >= 1.2 synopsis:            Applicative-based numeric instances category:            Data, Numerical@@ -11,7 +11,7 @@   .   Project wiki page: <http://haskell.org/haskellwiki/applicative-numbers>   .-  Copyright 2009 Conal Elliott; BSD3 license.+  Copyright 2009-2013 Conal Elliott; BSD3 license.   .   .   Instances of @Num@ classes for applicative functors.  To be @#include@'d after@@ -46,7 +46,7 @@ maintainer:          conal@conal.net homepage:            http://haskell.org/haskellwiki/applicative-numbers package-url:         http://code.haskell.org/applicative-numbers-copyright:           (c) 2009 by Conal Elliott+copyright:           (c) 2009-2011 by Conal Elliott license:             BSD3 license-file:        COPYING stability:           experimental@@ -61,6 +61,13 @@   exposed-modules:                             Data.Numeric.Function   install-includes:    ApplicativeNumeric-inc.hs+                       ApplicativeNumeric-inc.lhs++--                        T1.hs+--                        T1.lhs++-- T1 is for testing+   ghc-options:         -Wall ---  ghc-prof-options:    -prof -auto-all + ghc-prof-options:    -prof -auto-all 
src/ApplicativeNumeric-inc.hs view
@@ -1,7 +1,7 @@ {----------------------------------------------------------------------- Meta-Module :  ApplicativeNumeric-inc Copyright   :  (c) Conal Elliott 2008-License     :  GPL-3+License     :  BSD3  Maintainer  :  conal@conal.net Stability   :  experimental@@ -20,7 +20,9 @@  -- TODO: splice APPLICATIVE into the error message.  I don't have the CPP chops. --- Eq & Show are prerequisites for Num, so they have to be provided somehow+-- Until GHC 7.4 (base 4.5.0.0), Eq & Show were prerequisites for Num, so they+-- had to be provided somehow. I still need Ord for the Real instance and Eq for+-- the Ord instance.  -- Hack: the Functor [] is a no-op that allows for a ","-terminated CONSTRAINTS -- Requires FlexibleContexts
+ src/ApplicativeNumeric-inc.lhs view
@@ -0,0 +1,127 @@+-*- markdown -*-++Meta-Module :  ApplicativeNumeric-inc+Copyright   :  (c) Conal Elliott 2008+License     :  BSD3++Maintainer  :  conal@conal.net+Stability   :  experimental++This meta-module is just like ApplicativeNumeric-inc.hs, but is suitable+for including into literate sources. I don't know how to avoid redundancy.++> ++#ifndef CONSTRAINTS+#define CONSTRAINTS+#endif++#ifndef noOv_DEFINED++> noOv :: String -> a+> noOv meth = error $ meth ++ ": No overloading"++#define noOv_DEFINED+#endif++TODO: splice APPLICATIVE into the error message.  I don't have the CPP chops.++Eq & Show are prerequisites for Num, so they have to be provided somehow++Hack: the Functor [] is a no-op that allows for a ","-terminated CONSTRAINTS+Requires FlexibleContexts++#ifdef INSTANCE_Eq+> instance (CONSTRAINTS Functor []) => Eq (APPLICATIVE applicative_arg) where (==) = noOv "(==)"+#endif++#ifdef INSTANCE_Ord+> instance (CONSTRAINTS Ord applicative_arg) => Ord (APPLICATIVE applicative_arg) where+>   { min = liftA2 min ; max = liftA2 max }+#endif++#ifdef INSTANCE_Show+> instance Show (APPLICATIVE applicative_arg) where+>   { show      = noOv "show"+>   ; showsPrec = noOv "showsPrec"+>   ; showList  = noOv "showList"+>   }+#endif++#ifdef INSTANCE_Enum+> instance (CONSTRAINTS Enum applicative_arg) => Enum (APPLICATIVE applicative_arg) where+>   { succ           = fmap succ+>   ; pred           = fmap pred+>   ; toEnum         = pure . toEnum+>   ; fromEnum       = noOv "fromEnum"+>   ; enumFrom       = noOv "enumFrom"+>   ; enumFromThen   = noOv "enumFromThen"+>   ; enumFromTo     = noOv "enumFromTo"+>   ; enumFromThenTo = noOv "enumFromThenTo"+>   }+#endif++> instance (CONSTRAINTS Num applicative_arg) => Num (APPLICATIVE applicative_arg) where+>   negate      = fmap negate+>   (+)         = liftA2 (+)+>   (*)         = liftA2 (*)+>   fromInteger = pure . fromInteger+>   abs         = fmap abs+>   signum      = fmap signum++> instance (CONSTRAINTS Num applicative_arg, Ord applicative_arg) => Real (APPLICATIVE applicative_arg) where+>   toRational = noOv "toRational"++> instance (CONSTRAINTS Integral applicative_arg) => Integral (APPLICATIVE applicative_arg) where+>   quot          = liftA2 quot+>   rem           = liftA2 rem+>   div           = liftA2 div+>   mod           = liftA2 mod+>   toInteger     = noOv "toInteger"+>   x `quotRem` y = (x `quot` y, x `rem` y)+>   x `divMod`  y = (x `div`  y, x `mod` y)++> instance (CONSTRAINTS Fractional applicative_arg) => Fractional (APPLICATIVE applicative_arg) where+>   recip        = fmap recip+>   fromRational = pure . fromRational++> instance (CONSTRAINTS Floating applicative_arg) => Floating (APPLICATIVE applicative_arg) where+>   pi    = pure pi+>   sqrt  = fmap sqrt+>   exp   = fmap exp+>   log   = fmap log+>   sin   = fmap sin+>   cos   = fmap cos+>   asin  = fmap asin+>   atan  = fmap atan+>   acos  = fmap acos+>   sinh  = fmap sinh+>   cosh  = fmap cosh+>   asinh = fmap asinh+>   atanh = fmap atanh+>   acosh = fmap acosh++> instance (CONSTRAINTS RealFrac applicative_arg) => RealFrac (APPLICATIVE applicative_arg) where+>   properFraction = noOv "properFraction"+>   truncate       = noOv "truncate"+>   round          = noOv "round"+>   ceiling        = noOv "ceiling"+>   floor          = noOv "floor"++> instance (CONSTRAINTS RealFloat applicative_arg) => RealFloat (APPLICATIVE applicative_arg) where+>   floatRadix     = noOv "floatRadix"+>   floatDigits    = noOv "floatDigits"+>   floatRange     = noOv "floatRange"+>   decodeFloat    = noOv "decodeFloat"+>   encodeFloat    = ((.).(.)) pure encodeFloat+>   exponent       = noOv "exponent"+>   significand    = noOv "significand"+>   scaleFloat n   = fmap (scaleFloat n)+>   isNaN          = noOv "isNaN"+>   isInfinite     = noOv "isInfinite"+>   isDenormalized = noOv "isDenormalized"+>   isNegativeZero = noOv "isNegativeZero"+>   isIEEE         = noOv "isIEEE"+>   atan2          = liftA2 atan2++#undef APPLICATIVE
src/Data/Numeric/Function.hs view
@@ -27,5 +27,9 @@ #define INSTANCE_Ord #define INSTANCE_Enum -#define APPLICATIVE ((->) a)+-- #define APPLICATIVE ((->) a)+-- Avoid GHC 7.6.3 bug (?) by stripping the parens. Luckily, they're not needed here.+-- The Eq instance for (((->) a) b) is not recognized as equivalent to (a -> b).++#define APPLICATIVE (->) a #include "ApplicativeNumeric-inc.hs"
− wikipage.tw
@@ -1,14 +0,0 @@-[[Category:Packages]]-[[Category:Applicative]]-[[Category:Mathematics]]--== Abstract ==--Any applicative functor can be given numeric instances in a boilerplate way.-The '''applicative-numbers''' package provides an include file that makes it a snap to define these instances.--Besides this wiki page, here are more ways to find out about applicative-numbers:-* Visit the [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/applicative-numbers Hackage page] for library documentation and to download & install.-* Or install with <tt>cabal install applicative-numbers</tt>.-* Get the code repository: <tt>darcs get http://code.haskell.org/~conal/code/applicative-numbers</tt>.-<!-- * See the [[applicative-numbers/Versions| version history]]. -->