packages feed

ghc-typelits-knownnat 0.3.1 → 0.4

raw patch · 7 files changed

+25/−45 lines, 7 filesdep −singletonsdep ~ghcPVP ok

version bump matches the API change (PVP)

Dependencies removed: singletons

Dependency ranges changed: ghc

API changes (from Hackage documentation)

- GHC.TypeLits.KnownNat: instance (GHC.TypeLits.KnownNat a, GHC.TypeLits.KnownNat b) => GHC.TypeLits.KnownNat.KnownNat2 "GHC.TypeLits.*" a b
- GHC.TypeLits.KnownNat: instance (GHC.TypeLits.KnownNat a, GHC.TypeLits.KnownNat b) => GHC.TypeLits.KnownNat.KnownNat2 "GHC.TypeLits.+" a b
- GHC.TypeLits.KnownNat: instance (GHC.TypeLits.KnownNat a, GHC.TypeLits.KnownNat b) => GHC.TypeLits.KnownNat.KnownNat2 "GHC.TypeLits.^" a b
- GHC.TypeLits.KnownNat: instance (GHC.TypeLits.KnownNat a, GHC.TypeLits.KnownNat b, b GHC.TypeLits.<= a) => GHC.TypeLits.KnownNat.KnownNat2 "GHC.TypeLits.-" a b
- GHC.TypeLits.KnownNat: type family KnownNatF3 f :: Nat ~> (Nat ~> (Nat ~> Nat));
- GHC.TypeLits.KnownNat: }
+ GHC.TypeLits.KnownNat: instance (GHC.TypeNats.KnownNat a, GHC.TypeNats.KnownNat b) => GHC.TypeLits.KnownNat.KnownNat2 "GHC.TypeNats.*" a b
+ GHC.TypeLits.KnownNat: instance (GHC.TypeNats.KnownNat a, GHC.TypeNats.KnownNat b) => GHC.TypeLits.KnownNat.KnownNat2 "GHC.TypeNats.+" a b
+ GHC.TypeLits.KnownNat: instance (GHC.TypeNats.KnownNat a, GHC.TypeNats.KnownNat b) => GHC.TypeLits.KnownNat.KnownNat2 "GHC.TypeNats.^" a b
+ GHC.TypeLits.KnownNat: instance (GHC.TypeNats.KnownNat a, GHC.TypeNats.KnownNat b, b GHC.TypeNats.<= a) => GHC.TypeLits.KnownNat.KnownNat2 "GHC.TypeNats.-" a b
- GHC.TypeLits.KnownNat: SNatKn :: Integer -> SNatKn
+ GHC.TypeLits.KnownNat: SNatKn :: Natural -> SNatKn
- GHC.TypeLits.KnownNat: class KnownNat1 (f :: Symbol) (a :: Nat) where type KnownNatF1 f :: Nat ~> Nat where {
+ GHC.TypeLits.KnownNat: class KnownNat1 (f :: Symbol) (a :: Nat)
- GHC.TypeLits.KnownNat: class KnownNat2 (f :: Symbol) (a :: Nat) (b :: Nat) where type KnownNatF2 f :: Nat ~> (Nat ~> Nat) where {
+ GHC.TypeLits.KnownNat: class KnownNat2 (f :: Symbol) (a :: Nat) (b :: Nat)
- GHC.TypeLits.KnownNat: class KnownNat3 (f :: Symbol) (a :: Nat) (b :: Nat) (c :: Nat) where type KnownNatF3 f :: Nat ~> (Nat ~> (Nat ~> Nat)) where {
+ GHC.TypeLits.KnownNat: class KnownNat3 (f :: Symbol) (a :: Nat) (b :: Nat) (c :: Nat)
- GHC.TypeLits.KnownNat: natSing1 :: KnownNat1 f a => SNatKn (KnownNatF1 f @@ a)
+ GHC.TypeLits.KnownNat: natSing1 :: KnownNat1 f a => SNatKn f
- GHC.TypeLits.KnownNat: natSing2 :: KnownNat2 f a b => SNatKn ((KnownNatF2 f @@ a) @@ b)
+ GHC.TypeLits.KnownNat: natSing2 :: KnownNat2 f a b => SNatKn f
- GHC.TypeLits.KnownNat: natSing3 :: KnownNat3 f a b c => SNatKn (((KnownNatF3 f @@ a) @@ b) @@ c)
+ GHC.TypeLits.KnownNat: natSing3 :: KnownNat3 f a b c => SNatKn f
- GHC.TypeLits.KnownNat: newtype SNatKn (n :: Nat)
+ GHC.TypeLits.KnownNat: newtype SNatKn (f :: Symbol)

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog for the [`ghc-typelits-knownnat`](http://hackage.haskell.org/package/ghc-typelits-knownnat) package +## 0.4 *January 4th, 2018*+* Add partial GHC 8.4.1-alpha1 support+* Drop `singletons` dependency [#15](https://github.com/clash-lang/ghc-typelits-knownnat/issues/15)+  * `KnownNatN` classes no longer have the `KnownNatFN` associated type family+ ## 0.3.1 *August 17th 2017* * Fix testsuite for GHC 8.2.1 
LICENSE view
@@ -1,6 +1,6 @@-Copyright (c) 2015-2016, University of Twente,-              2017, QBayLogic,-              2017, Google Inc.+Copyright (c) 2016     , University of Twente,+              2017-2018, QBayLogic B.V.,+              2017     , Google Inc. All rights reserved.  Redistribution and use in source and binary forms, with or without
README.md view
@@ -52,15 +52,12 @@ type family Max (a :: Nat) (b :: Nat) :: Nat where   Max 0 b = b   Max a b = If (a <=? b) b a--$(genDefunSymbols [''Max]) -- creates the 'MaxSym0' symbol ```  and corresponding `KnownNat2` instance:  ```haskell instance (KnownNat a, KnownNat b) => KnownNat2 "TestFunctions.Max" a b where-  type KnownNatF2 "TestFunctions.Max" = MaxSym0   natSing2 = let x = natVal (Proxy @ a)                  y = natVal (Proxy @ b)                  z = max x y
ghc-typelits-knownnat.cabal view
@@ -1,5 +1,5 @@ name:                ghc-typelits-knownnat-version:             0.3.1+version:             0.4 synopsis:            Derive KnownNat constraints from other KnownNat constraints description:   A type checker plugin for GHC that can derive \"complex\" @KnownNat@@@ -45,12 +45,15 @@ license-file:        LICENSE author:              Christiaan Baaij maintainer:          christiaan.baaij@gmail.com-copyright:           Copyright © 2016, University of Twente, 2017 QBayLogic+copyright:           Copyright © 2016     , University of Twente,+                                 2017-2018, QBayLogic B.V.,+                                 2017     , Google Inc. category:            Type System build-type:          Simple extra-source-files:  README.md                      CHANGELOG.md cabal-version:       >=1.10+tested-with:         GHC==8.0.2, GHC == 8.2.2, GHC == 8.4.1  source-repository head   type: git@@ -82,10 +85,9 @@                        UndecidableInstances                        ViewPatterns   build-depends:       base                      >= 4.9      && <5,-                       ghc                       >= 8.0.1    && <8.4,+                       ghc                       >= 8.0.1    && <8.6,                        ghc-tcplugins-extra       >= 0.2,                        ghc-typelits-natnormalise >= 0.5.2    && <0.6,-                       singletons                >= 2.2      && <2.4,                        transformers              >= 0.5.2.0  && <0.6,                        template-haskell          >= 2.11.0.0 && <2.13   hs-source-dirs:      src@@ -102,7 +104,6 @@   build-depends:       base                      >= 4.8   && <5,                        ghc-typelits-knownnat,                        ghc-typelits-natnormalise >= 0.5   && <0.6,-                       singletons                >= 2.2   && <2.4,                        tasty                     >= 0.10,                        tasty-hunit               >= 0.9,                        tasty-quickcheck          >= 0.8
src/GHC/TypeLits/KnownNat.hs view
@@ -1,5 +1,7 @@ {-|-Copyright  :  (C) 2016, University of Twente+Copyright  :  (C) 2016     , University of Twente,+                  2017-2018, QBayLogic B.V.,+                  2017     , Google Inc. License    :  BSD2 (see the file LICENSE) Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com> @@ -30,13 +32,9 @@              UndecidableInstances \#-\}  import Data.Proxy            (Proxy (..))-import Data.Singletons.TH    (genDefunSymbols) import GHC.TypeLits.KnownNat -$(genDefunSymbols [''Max]) -- creates the \'MaxSym0\' symbol- instance (KnownNat a, KnownNat b) => 'KnownNat2' $('nameToSymbol' ''Max) a b where-  type 'KnownNatF2' $('nameToSymbol' ''Max) = MaxSym0   natSing2 = let x = natVal (Proxy @a)                  y = natVal (Proxy @b)                  z = max x y@@ -95,8 +93,6 @@ {-# LANGUAGE TypeApplications      #-} {-# LANGUAGE TypeOperators         #-} {-# LANGUAGE TypeFamilies          #-}-{-# LANGUAGE TypeInType            #-}-{-# LANGUAGE UndecidableInstances  #-}  {-# LANGUAGE Trustworthy #-} @@ -121,20 +117,16 @@ import GHC.TypeNats   (KnownNat, Nat, type (+), type (*), type (^), type (-), type (<=), natVal) import GHC.TypeLits           (Symbol)+import Numeric.Natural        (Natural) #else import GHC.TypeLits           (KnownNat, Nat, Symbol, type (+), type (*),                                type (^), type (-), type (<=), natVal) #endif-import Data.Singletons        (type (~>), type (@@))-import Data.Promotion.Prelude (type (:+$), type (:*$), type (:^$), type (:-$))-#if MIN_VERSION_ghc(8,2,0)-import Numeric.Natural        (Natural)-#endif  import GHC.TypeLits.KnownNat.TH  -- | Singleton natural number-newtype SNatKn (n :: Nat) =+newtype SNatKn (f :: Symbol) = #if MIN_VERSION_ghc(8,2,0)   SNatKn Natural #else@@ -147,8 +139,7 @@ -- type-level operation. Use 'nameToSymbol' to get the fully qualified -- TH Name as a 'Symbol' class KnownNat1 (f :: Symbol) (a :: Nat) where-  type KnownNatF1 f :: Nat ~> Nat-  natSing1 :: SNatKn (KnownNatF1 f @@ a)+  natSing1 :: SNatKn f  -- | Class for arithmetic functions with /two/ arguments. --@@ -156,8 +147,7 @@ -- type-level operation. Use 'nameToSymbol' to get the fully qualified -- TH Name as a 'Symbol' class KnownNat2 (f :: Symbol) (a :: Nat) (b :: Nat) where-  type KnownNatF2 f :: Nat ~> Nat ~> Nat-  natSing2 :: SNatKn (KnownNatF2 f @@ a @@ b)+  natSing2 :: SNatKn f  -- | Class for arithmetic functions with /three/ arguments. --@@ -165,24 +155,20 @@ -- type-level operation. Use 'nameToSymbol' to get the fully qualified -- TH Name as a 'Symbol' class KnownNat3 (f :: Symbol) (a :: Nat) (b :: Nat) (c :: Nat) where-  type KnownNatF3 f :: Nat ~> Nat ~> Nat ~> Nat-  natSing3 :: SNatKn (KnownNatF3 f @@ a @@ b @@ c)+  natSing3 :: SNatKn f  -- | 'KnownNat2' instance for "GHC.TypeLits"' 'GHC.TypeLits.+' instance (KnownNat a, KnownNat b) => KnownNat2 $(nameToSymbol ''(+)) a b where-  type KnownNatF2 $(nameToSymbol ''(+)) = (:+$)   natSing2 = SNatKn (natVal (Proxy @a) + natVal (Proxy @b))   {-# INLINE natSing2 #-}  -- | 'KnownNat2' instance for "GHC.TypeLits"' 'GHC.TypeLits.*' instance (KnownNat a, KnownNat b) => KnownNat2 $(nameToSymbol ''(*)) a b where-  type KnownNatF2 $(nameToSymbol ''(*)) = (:*$)   natSing2 = SNatKn (natVal (Proxy @a) * natVal (Proxy @b))   {-# INLINE natSing2 #-}  -- | 'KnownNat2' instance for "GHC.TypeLits"' 'GHC.TypeLits.^' instance (KnownNat a, KnownNat b) => KnownNat2 $(nameToSymbol ''(^)) a b where-  type KnownNatF2 $(nameToSymbol ''(^)) = (:^$)   natSing2 = let x = natVal (Proxy @ a)                  y = natVal (Proxy @ b)                  z = case x of@@ -193,6 +179,5 @@  -- | 'KnownNat2' instance for "GHC.TypeLits"' 'GHC.TypeLits.-' instance (KnownNat a, KnownNat b, b <= a) => KnownNat2 $(nameToSymbol ''(-)) a b where-  type KnownNatF2 $(nameToSymbol ''(-)) = (:-$)   natSing2 = SNatKn (natVal (Proxy @a) - natVal (Proxy @b))   {-# INLINE natSing2 #-}
src/GHC/TypeLits/KnownNat/Solver.hs view
@@ -1,5 +1,7 @@ {-|-Copyright  :  (C) 2016, University of Twente+Copyright  :  (C) 2016     , University of Twente,+                  2017-2018, QBayLogic B.V.,+                  2017     , Google Inc. License    :  BSD2 (see the file LICENSE) Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com> @@ -51,15 +53,12 @@ type family Max (a :: Nat) (b :: Nat) :: Nat where   Max 0 b = b   Max a b = If (a <=? b) b a--$(genDefunSymbols [''Max]) -- creates the 'MaxSym0' symbol @  and corresponding @KnownNat2@ instance:  @ instance (KnownNat a, KnownNat b) => KnownNat2 \"TestFunctions.Max\" a b where-  type KnownNatF2 \"TestFunctions.Max\" = MaxSym0   natSing2 = let x = natVal (Proxy @ a)                  y = natVal (Proxy @ b)                  z = max x y
tests/TestFunctions.hs view
@@ -6,7 +6,6 @@ module TestFunctions where  import Data.Proxy            (Proxy (..))-import Data.Singletons.TH    (genDefunSymbols) import Data.Type.Bool        (If) import GHC.TypeLits.KnownNat #if __GLASGOW_HASKELL__ >= 802@@ -20,10 +19,7 @@   Max 0 b = b -- See [Note: single equation TFs are treated like synonyms]   Max a b = If (a <=? b) b a -genDefunSymbols [''Max]- instance (KnownNat a, KnownNat b) => KnownNat2 $(nameToSymbol ''Max) a b where-  type KnownNatF2 $(nameToSymbol ''Max) = MaxSym0   natSing2 = let x = natVal (Proxy @ a)                  y = natVal (Proxy @ b)                  z = max x y@@ -56,8 +52,6 @@  type family Log (n :: Nat) :: Nat where -genDefunSymbols [''Log]- #if __GLASGOW_HASKELL__ >= 802 logInt :: Natural -> Natural #else@@ -72,6 +66,5 @@              GT -> k - 1  instance (KnownNat a) => KnownNat1 $(nameToSymbol ''Log) a where-  type KnownNatF1 $(nameToSymbol ''Log) = LogSym0   natSing1 = let x = natVal (Proxy @ a)              in SNatKn (logInt x)