Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from symbol to intern as the former seems dormant #262

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gibbon-compiler/gibbon.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion gibbon-compiler/src/Gibbon/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -67,6 +69,24 @@ import Gibbon.DynFlags

--------------------------------------------------------------------------------

newtype Symbol = Symbol InternedString
deriving (Eq, Ord)

instance Show Symbol where
showsPrec d s = showsPrec d (unintern s)

instance Read Symbol where
readsPrec _d t = [(intern s, t') | (s, t') <- readList t]

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)
Expand Down
1 change: 0 additions & 1 deletion gibbon-compiler/src/Gibbon/L0/ElimNewtype.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion gibbon-compiler/src/Gibbon/L1/GenSML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion gibbon-compiler/src/Gibbon/Passes/Fusion2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading