packages feed

exact-pi 0.3.1.0 → 0.4.0.0

raw patch · 3 files changed

+14/−8 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.ExactPi.TypeLevel: type MinCtxt v a = (KnownExactPi v, MinCtxt' v a, KnownMinCtxt (MinCtxt' v))
- Data.ExactPi.TypeLevel: injMin :: (KnownExactPi v, MinCtxt v a, KnownMinCtxt (MinCtxt v)) => Proxy v -> a
+ Data.ExactPi.TypeLevel: injMin :: (MinCtxt v a) => Proxy v -> a

Files

changelog.md view
@@ -1,3 +1,7 @@+0.4.0.0
+-------
+* Added simpler constraints for converting ExactPi types to terms with the minimal context.
+
 0.3.1.0
 -------
 * Added support for exactly comparing values.
exact-pi.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/
 
 name:                exact-pi
-version:             0.3.1.0
+version:             0.4.0.0
 synopsis:            Exact rational multiples of pi (and integer powers of pi)
 description:         Provides an exact representation for rational multiples of pi alongside an approximate representation of all reals.
                      Useful for storing and computing with conversion factors between physical units.
src/Data/ExactPi/TypeLevel.hs view
@@ -28,7 +28,7 @@   type ExactNatural,
   type One, type Pi,
   -- * Conversion to Term Level
-  type MinCtxt,
+  type MinCtxt, type MinCtxt',
   injMin
 )
 where
@@ -69,11 +69,13 @@ 
 -- | Determines the minimum context required for a numeric type to hold the value
 -- associated with a specific 'ExactPi'' type.
-type family MinCtxt (v :: ExactPi') :: * -> Constraint where
-  MinCtxt ('ExactPi' 'Zero p 1) = Num
-  MinCtxt ('ExactPi' 'Zero p q) = Fractional
-  MinCtxt ('ExactPi' z p q)     = Floating
+type family MinCtxt' (v :: ExactPi') :: * -> Constraint where
+  MinCtxt' ('ExactPi' 'Zero p 1) = Num
+  MinCtxt' ('ExactPi' 'Zero p q) = Fractional
+  MinCtxt' ('ExactPi' z p q)     = Floating
 
+type MinCtxt v a = (KnownExactPi v, MinCtxt' v a, KnownMinCtxt (MinCtxt' v))
+
 -- | A KnownMinCtxt is a contraint on values sufficient to allow us to inject certain
 -- 'ExactPi' values into types that satisfy the constraint.
 class KnownMinCtxt (c :: * -> Constraint) where
@@ -98,8 +100,8 @@ -- 
 -- When the value is known to be an integer, it can be returned as any instance of 'Num'. Similarly,
 -- rationals require 'Fractional', and values that involve 'pi' require 'Floating'.
-injMin :: forall v a.(KnownExactPi v, MinCtxt v a, KnownMinCtxt (MinCtxt v)) => Proxy v -> a
-injMin = inj (Proxy :: Proxy (MinCtxt v)) . exactPiVal
+injMin :: forall v a.(MinCtxt v a) => Proxy v -> a
+injMin = inj (Proxy :: Proxy (MinCtxt' v)) . exactPiVal
 
 instance (KnownTypeInt z, KnownNat p, KnownNat q, 1 <= q) => KnownExactPi ('ExactPi' z p q) where
   exactPiVal _ = Exact z' (p' % q')