diff --git a/gibbon-compiler/gibbon.cabal b/gibbon-compiler/gibbon.cabal index 00851dc1c..7b0a9116d 100644 --- a/gibbon-compiler/gibbon.cabal +++ b/gibbon-compiler/gibbon.cabal @@ -115,7 +115,7 @@ library , hse-cpp >= 0.1 && < 1 , s-cargot >= 0.1.3 && < 1 , srcloc >= 0.6 && < 1 - , symbol >= 0.2.4 && < 1 + , intern ^>= 0.9 -- Pretty printers: , pretty >= 1.1.1.3 && < 1.2 , GenericPretty >= 1.2.1 && < 2 diff --git a/gibbon-compiler/src/Gibbon/Common.hs b/gibbon-compiler/src/Gibbon/Common.hs index c4dab877e..09d440cfe 100644 --- a/gibbon-compiler/src/Gibbon/Common.hs +++ b/gibbon-compiler/src/Gibbon/Common.hs @@ -10,6 +10,7 @@ module Gibbon.Common -- * Variables Var(..), LocVar, RegVar, fromVar, toVar, varAppend, toEndV, toSeqV, cleanFunName , TyVar(..), isUserTv + , Symbol, intern, unintern -- * Gensym monad , SyM, gensym, gensym_tag, genLetter, newUniq, runSyM @@ -49,7 +50,8 @@ import Data.Char import qualified Data.List as L import Data.Map as M import Data.String -import Data.Symbol +import qualified Data.Interned as DI +import Data.Interned.String import Data.Word import GHC.Generics import GHC.Stack (HasCallStack) @@ -67,6 +69,21 @@ import Gibbon.DynFlags -------------------------------------------------------------------------------- +newtype Symbol = Symbol InternedString + deriving (Eq, Ord, Show) + +instance Read Symbol where + readsPrec _ s = [(Symbol $ DI.intern s, "")] + +instance IsString Symbol where + fromString = intern + +intern :: String -> Symbol +intern = Symbol . DI.intern + +unintern :: Symbol -> String +unintern (Symbol is) = DI.unintern is + -- type CursorVar = Var newtype Var = Var Symbol deriving (Eq, Ord, Read, Show) diff --git a/gibbon-compiler/src/Gibbon/L0/ElimNewtype.hs b/gibbon-compiler/src/Gibbon/L0/ElimNewtype.hs index a4722e968..5e22476ad 100644 --- a/gibbon-compiler/src/Gibbon/L0/ElimNewtype.hs +++ b/gibbon-compiler/src/Gibbon/L0/ElimNewtype.hs @@ -6,7 +6,6 @@ import Gibbon.Common import Control.Arrow import qualified Data.Map as M import qualified Data.Set as S -import Data.Symbol ( unintern ) elimNewtypes :: Monad m => Prog0 -> m Prog0 elimNewtypes = pure . elimProgram diff --git a/gibbon-compiler/src/Gibbon/L1/GenSML.hs b/gibbon-compiler/src/Gibbon/L1/GenSML.hs index 1c06a7e5d..7a4fa76e9 100644 --- a/gibbon-compiler/src/Gibbon/L1/GenSML.hs +++ b/gibbon-compiler/src/Gibbon/L1/GenSML.hs @@ -9,7 +9,6 @@ import Control.Monad import Data.Map hiding (foldr, fold, null, empty) import qualified Data.Map as Map import qualified Data.Set as Set -import Data.Symbol import Data.Foldable hiding ( toList ) import Data.Graph diff --git a/gibbon-compiler/src/Gibbon/Passes/Fusion2.hs b/gibbon-compiler/src/Gibbon/Passes/Fusion2.hs index f024df735..b1cff849b 100644 --- a/gibbon-compiler/src/Gibbon/Passes/Fusion2.hs +++ b/gibbon-compiler/src/Gibbon/Passes/Fusion2.hs @@ -11,7 +11,6 @@ import qualified Data.Map as M import qualified Data.List as L import qualified Data.Set as S import qualified Data.Vector as V -import Data.Symbol import Data.Char ( toLower ) import Debug.Trace import Control.DeepSeq