Skip to content

Commit

Permalink
GHC-9.8 compatibility: Uniques contain Ints instead of Word64s.
Browse files Browse the repository at this point in the history
  • Loading branch information
gergoerdi committed Oct 16, 2024
1 parent 39c7ce4 commit dc25324
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions liquidhaskell-boot/liquidhaskell-boot.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ library
Language.Haskell.Liquid.Constraint.Types
Language.Haskell.Liquid.Constraint.Relational
Liquid.GHC.API
Liquid.GHC.API.Compat
Liquid.GHC.API.Extra
Liquid.GHC.API.StableModule
Language.Haskell.Liquid.GHC.CoreToLogic
Expand Down
1 change: 1 addition & 0 deletions liquidhaskell-boot/src-ghc/Liquid/GHC/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Liquid.GHC.API (
) where

import Liquid.GHC.API.Extra as Ghc
import Liquid.GHC.API.Compat as Ghc

import GHC as Ghc
( Class
Expand Down
15 changes: 15 additions & 0 deletions liquidhaskell-boot/src-ghc/Liquid/GHC/API/Compat.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Liquid.GHC.API.Compat (
UniqueId
, toUniqueId
) where

import Data.Word (Word64)

----------------------
-- Uniques
----------------------

type UniqueId = Word64

toUniqueId :: Word64 -> UniqueId
toUniqueId = id
8 changes: 4 additions & 4 deletions liquidhaskell-boot/src/Language/Haskell/Liquid/GHC/Misc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ maybeAuxVar s
name = mkInternalName (mkUnique 'x' uid) occ noSrcSpan
occ = mkVarOcc (T.unpack (symbolText sym))

stringTyCon :: Char -> Word64 -> String -> TyCon
stringTyCon :: Char -> UniqueId -> String -> TyCon
stringTyCon = stringTyConWithKind anyTy

-- FIXME: reusing uniques like this is really dangerous
stringTyConWithKind :: Kind -> Char -> Word64 -> String -> TyCon
stringTyConWithKind :: Kind -> Char -> UniqueId -> String -> TyCon
stringTyConWithKind k c n s = Ghc.mkPrimTyCon name [] k []
where
name = mkInternalName (mkUnique c n) occ noSrcSpan
Expand Down Expand Up @@ -508,8 +508,8 @@ takeModuleUnique = mungeNames tailName sepUnique "takeModuleUnique: "
where
tailName msg = symbol . safeLast msg

splitModuleUnique :: Symbol -> (Symbol, Word64)
splitModuleUnique x = (dropModuleNamesAndUnique x, base62ToW (takeModuleUnique x))
splitModuleUnique :: Symbol -> (Symbol, UniqueId)
splitModuleUnique x = (dropModuleNamesAndUnique x, toUniqueId $ base62ToW (takeModuleUnique x))

base62ToW :: Symbol -> Word64
base62ToW s = fromMaybe (errorstar "base62ToW Out Of Range") $ go (F.symbolText s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

module Language.Haskell.Liquid.Transforms.ANF (anormalize) where

import Data.Word (Word64)
import Debug.Trace (trace)
import Prelude hiding (error)
import Language.Haskell.Liquid.GHC.TypeRep
Expand Down Expand Up @@ -355,7 +354,7 @@ freshNormalVar γ t = do
let sp = Sp.srcSpan (aeSrcSpan γ)
return (mkUserLocalOrCoVar (anfOcc i) u Ghc.ManyTy t sp)

anfOcc :: Word64 -> OccName
anfOcc :: UniqueId -> OccName
anfOcc = mkVarOccFS . GM.symbolFastString . F.intSymbol F.anfPrefix

data AnfEnv = AnfEnv
Expand Down

0 comments on commit dc25324

Please sign in to comment.