packages feed

ghc-typelits-knownnat 0.4 → 0.4.1

raw patch · 3 files changed

+25/−5 lines, 3 filesdep ~ghc-tcplugins-extradep ~ghc-typelits-natnormalisedep ~template-haskellPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: ghc-tcplugins-extra, ghc-typelits-natnormalise, template-haskell

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,8 @@ # Changelog for the [`ghc-typelits-knownnat`](http://hackage.haskell.org/package/ghc-typelits-knownnat) package +## 0.4.1 *March 17th, 2018*+* Add support for GHC 8.4.1+ ## 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)
ghc-typelits-knownnat.cabal view
@@ -1,5 +1,5 @@ name:                ghc-typelits-knownnat-version:             0.4+version:             0.4.1 synopsis:            Derive KnownNat constraints from other KnownNat constraints description:   A type checker plugin for GHC that can derive \"complex\" @KnownNat@@@ -86,10 +86,10 @@                        ViewPatterns   build-depends:       base                      >= 4.9      && <5,                        ghc                       >= 8.0.1    && <8.6,-                       ghc-tcplugins-extra       >= 0.2,+                       ghc-tcplugins-extra       >= 0.2.4,                        ghc-typelits-natnormalise >= 0.5.2    && <0.6,                        transformers              >= 0.5.2.0  && <0.6,-                       template-haskell          >= 2.11.0.0 && <2.13+                       template-haskell          >= 2.11.0.0 && <2.14   hs-source-dirs:      src   default-language:    Haskell2010   if flag(deverror)@@ -103,7 +103,7 @@   Other-Modules:       TestFunctions   build-depends:       base                      >= 4.8   && <5,                        ghc-typelits-knownnat,-                       ghc-typelits-natnormalise >= 0.5   && <0.6,+                       ghc-typelits-natnormalise >= 0.5.9 && <0.6,                        tasty                     >= 0.10,                        tasty-hunit               >= 0.9,                        tasty-quickcheck          >= 0.8
src/GHC/TypeLits/KnownNat/Solver.hs view
@@ -84,6 +84,7 @@  -} +{-# LANGUAGE CPP           #-} {-# LANGUAGE LambdaCase    #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE ViewPatterns  #-}@@ -100,6 +101,9 @@ import Data.Maybe                   (catMaybes,mapMaybe) import GHC.TcPluginM.Extra          (lookupModule, lookupName, newWanted,                                      tracePlugin)+#if MIN_VERSION_ghc(8,4,0)+import GHC.TcPluginM.Extra          (flattenGivens, mkSubst', substType)+#endif import GHC.TypeLits.Normalise.SOP   (SOP (..), Product (..), Symbol (..)) import GHC.TypeLits.Normalise.Unify (CType (..),normaliseNat,reifySOP) @@ -115,7 +119,10 @@ import Plugins    (Plugin (..), defaultPlugin) import PrelNames  (knownNatClassName) import TcEvidence (EvTerm (..), EvLit (EvNum), mkEvCast, mkTcSymCo, mkTcTransCo)-import TcPluginM  (TcPluginM, tcLookupClass, getInstEnvs, zonkCt)+#if !MIN_VERSION_ghc(8,4,0)+import TcPluginM  (zonkCt)+#endif+import TcPluginM  (TcPluginM, tcLookupClass, getInstEnvs) import TcRnTypes  (Ct, TcPlugin(..), TcPluginResult (..), ctEvidence, ctEvLoc,                    ctEvPred, ctEvTerm, ctLoc, ctLocSpan, isWanted,                    mkNonCanonical, setCtLoc, setCtLocSpan)@@ -235,12 +242,22 @@ solveKnownNat defs  givens  _deriveds wanteds = do   -- GHC 7.10 puts deriveds with the wanteds, so filter them out   let wanteds'   = filter (isWanted . ctEvidence) wanteds+#if MIN_VERSION_ghc(8,4,0)+      subst      = mkSubst' givens+      kn_wanteds = map (\(x,y,z) -> (x,y,substType subst z))+                 $ mapMaybe toKnConstraint wanteds'+#else       kn_wanteds = mapMaybe toKnConstraint wanteds'+#endif   case kn_wanteds of     [] -> return (TcPluginOk [] [])     _  -> do       -- Make a lookup table for all the [G]iven constraints+#if MIN_VERSION_ghc(8,4,0)+      let given_map = map toGivenEntry (givens ++ flattenGivens givens)+#else       given_map <- mapM (fmap toGivenEntry . zonkCt) givens+#endif       -- Try to solve the wanted KnownNat constraints given the [G]iven       -- KnownNat constraints       (solved,new) <- (unzip . catMaybes) <$> (mapM (constraintToEvTerm defs given_map) kn_wanteds)