Skip to content

Commit

Permalink
Merge pull request #52 from clash-lang/modreduce
Browse files Browse the repository at this point in the history
Fix lookup `Div` and `Mod` GHC >= 9.2
  • Loading branch information
christiaanb authored Apr 16, 2024
2 parents 1eed8d3 + 0b2507a commit 473f7d2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.stack-work
dist-newstyle
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog for the [`ghc-typelits-extra`](http://hackage.haskell.org/package/ghc-typelits-extra) package

# Unreleased
* Fix faulty lookup for `Mod` and `Div` in GHC >= 9.2

# 0.4.7
* Fix Plugin silently fails when normalizing <= in GHC 9.4+ [#50](https://github.com/clash-lang/ghc-typelits-extra/issues/50)

Expand Down
7 changes: 3 additions & 4 deletions src-ghc-9.4/GHC/TypeLits/Extra/Solver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import GHC.TcPluginM.Extra
import GHC.Builtin.Names (eqPrimTyConKey, hasKey, getUnique)
import GHC.Builtin.Types (promotedTrueDataCon, promotedFalseDataCon)
import GHC.Builtin.Types (boolTy, naturalTy, cTupleDataCon, cTupleTyCon)
import GHC.Builtin.Types.Literals (typeNatTyCons)
import GHC.Builtin.Types.Literals (typeNatCmpTyCon)
import GHC.Builtin.Types.Literals (typeNatDivTyCon, typeNatModTyCon, typeNatCmpTyCon)
import GHC.Core.Coercion (mkUnivCo)
import GHC.Core.DataCon (dataConWrapId)
import GHC.Core.Predicate (EqRel (NomEq), Pred (EqPred, IrredPred), classifyPredType)
Expand Down Expand Up @@ -315,8 +314,8 @@ lookupExtraDefs = do
md2 <- lookupModule typeErrModule basePackage
ExtraDefs <$> look md "Max"
<*> look md "Min"
<*> pure (typeNatTyCons !! 5)
<*> pure (typeNatTyCons !! 6)
<*> pure typeNatDivTyCon
<*> pure typeNatModTyCon
<*> look md "FLog"
<*> look md "CLog"
<*> look md "Log"
Expand Down
8 changes: 4 additions & 4 deletions src-pre-ghc-9.4/GHC/TypeLits/Extra/Solver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import GHC.Builtin.Types (boolTy, naturalTy)
#else
import GHC.Builtin.Types (typeNatKind)
#endif
import GHC.Builtin.Types.Literals (typeNatTyCons)
import GHC.Builtin.Types.Literals (typeNatDivTyCon, typeNatModTyCon)
#if MIN_VERSION_ghc(9,2,0)
import GHC.Builtin.Types.Literals (typeNatCmpTyCon)
#else
Expand Down Expand Up @@ -82,7 +82,7 @@ import TyCoRep (Type (..))
import TysWiredIn (typeNatKind, promotedTrueDataCon, promotedFalseDataCon)
import TcTypeNats (typeNatLeqTyCon)
#if MIN_VERSION_ghc(8,4,0)
import TcTypeNats (typeNatTyCons)
import TcTypeNats (typeNatDivTyCon, typeNatModTyCon)
#else
import TcPluginM (zonkCt)
#endif
Expand Down Expand Up @@ -313,8 +313,8 @@ lookupExtraDefs = do
ExtraDefs <$> look md "Max"
<*> look md "Min"
#if MIN_VERSION_ghc(8,4,0)
<*> pure (typeNatTyCons !! 5)
<*> pure (typeNatTyCons !! 6)
<*> pure typeNatDivTyCon
<*> pure typeNatModTyCon
#else
<*> look md "Div"
<*> look md "Mod"
Expand Down

0 comments on commit 473f7d2

Please sign in to comment.