{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE RecordWildCards #-}

-- | The SymbolCache is used to cache lookups for specific symbols when using
-- the interpreter.
module GHC.Runtime.Interpreter.Types.SymbolCache (
     InterpSymbolCache(..)
   , mkInterpSymbolCache
   , lookupInterpSymbolCache
   , updateInterpSymbolCache
   , purgeInterpSymbolCache
   , InterpSymbol(..)
   , SuffixOrInterpreted(..)
   , interpSymbolName
   , interpSymbolSuffix
   , eliminateInterpSymbol
   , interpretedInterpSymbol
   ) where

import GHC.Prelude

import GHC.Types.Unique.FM
import GHC.Types.Name
import GHC.Data.FastString
import Foreign

import Control.Concurrent
import GHC.Utils.Outputable
import GHC.TypeLits


-- The symbols records the suffix which each cache deals with.
newtype SymbolCache (s :: Symbol) = SymbolCache { forall (s :: Symbol). SymbolCache s -> UniqFM Name (Ptr ())
_getSymbolCache :: UniqFM Name (Ptr ()) }

-- Each cache is keyed by Name, there is one cache for each type of symbol we will
-- potentially lookup. The caches are keyed by 'Name' so that it is not necessary to consult
-- a complicated `FastString` each time.
data InterpSymbolCache = InterpSymbolCache {
        InterpSymbolCache -> MVar (SymbolCache "closure")
interpClosureCache :: MVar (SymbolCache "closure")
      , InterpSymbolCache -> MVar (SymbolCache "con_info")
interpConInfoCache :: MVar (SymbolCache "con_info")
      , InterpSymbolCache -> MVar (SymbolCache "static_info")
interpStaticInfoCache :: MVar (SymbolCache "static_info")
      , InterpSymbolCache -> MVar (SymbolCache "bytes")
interpBytesCache   :: MVar (SymbolCache "bytes")
      , InterpSymbolCache -> MVar (UniqFM FastString (Ptr ()))
interpFaststringCache   :: MVar (UniqFM FastString (Ptr ()))
      }

data SuffixOrInterpreted = Suffix Symbol | Interpreted

data InterpSymbol (s :: SuffixOrInterpreted) where
  IClosureSymbol :: Name -> InterpSymbol (Suffix "closure")
  IConInfoSymbol :: Name -> InterpSymbol (Suffix "con_info")
  IStaticInfoSymbol :: Name -> InterpSymbol (Suffix "static_info")
  IBytesSymbol   :: Name -> InterpSymbol (Suffix "bytes")
  IFaststringSymbol   :: FastString -> InterpSymbol Interpreted

instance Outputable (InterpSymbol s) where
  ppr :: InterpSymbol s -> SDoc
ppr InterpSymbol s
s = InterpSymbol s
-> (InterpSymbol 'Interpreted -> SDoc)
-> (forall (x :: Symbol). InterpSymbol ('Suffix x) -> SDoc)
-> SDoc
forall (s :: SuffixOrInterpreted) r.
InterpSymbol s
-> (InterpSymbol 'Interpreted -> r)
-> (forall (x :: Symbol). InterpSymbol ('Suffix x) -> r)
-> r
eliminateInterpSymbol InterpSymbol s
s
            (\(IFaststringSymbol FastString
s) -> String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"interpreted:" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> FastString -> SDoc
forall a. Outputable a => a -> SDoc
ppr FastString
s)
            (\InterpSymbol ('Suffix x)
s -> String -> SDoc
forall doc. IsLine doc => String -> doc
text (InterpSymbol ('Suffix x) -> String
forall (s :: Symbol). InterpSymbol ('Suffix s) -> String
interpSymbolSuffix InterpSymbol ('Suffix x)
s) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
colon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr (InterpSymbol ('Suffix x) -> Name
forall (s :: Symbol). InterpSymbol ('Suffix s) -> Name
interpSymbolName InterpSymbol ('Suffix x)
s))

eliminateInterpSymbol :: InterpSymbol s -> (InterpSymbol Interpreted -> r)
                                        -> (forall x . InterpSymbol (Suffix x) -> r)
                                        -> r
eliminateInterpSymbol :: forall (s :: SuffixOrInterpreted) r.
InterpSymbol s
-> (InterpSymbol 'Interpreted -> r)
-> (forall (x :: Symbol). InterpSymbol ('Suffix x) -> r)
-> r
eliminateInterpSymbol InterpSymbol s
s InterpSymbol 'Interpreted -> r
k1 forall (x :: Symbol). InterpSymbol ('Suffix x) -> r
k2 =
  case InterpSymbol s
s of
    IFaststringSymbol {} -> InterpSymbol 'Interpreted -> r
k1 InterpSymbol s
InterpSymbol 'Interpreted
s
    IBytesSymbol {}      -> InterpSymbol ('Suffix "bytes") -> r
forall (x :: Symbol). InterpSymbol ('Suffix x) -> r
k2 InterpSymbol s
InterpSymbol ('Suffix "bytes")
s
    IStaticInfoSymbol {} -> InterpSymbol ('Suffix "static_info") -> r
forall (x :: Symbol). InterpSymbol ('Suffix x) -> r
k2 InterpSymbol s
InterpSymbol ('Suffix "static_info")
s
    IConInfoSymbol {}    -> InterpSymbol ('Suffix "con_info") -> r
forall (x :: Symbol). InterpSymbol ('Suffix x) -> r
k2 InterpSymbol s
InterpSymbol ('Suffix "con_info")
s
    IClosureSymbol {}    -> InterpSymbol ('Suffix "closure") -> r
forall (x :: Symbol). InterpSymbol ('Suffix x) -> r
k2 InterpSymbol s
InterpSymbol ('Suffix "closure")
s


interpSymbolName :: InterpSymbol (Suffix s) -> Name
interpSymbolName :: forall (s :: Symbol). InterpSymbol ('Suffix s) -> Name
interpSymbolName (IClosureSymbol Name
n) = Name
n
interpSymbolName (IConInfoSymbol Name
n) = Name
n
interpSymbolName (IStaticInfoSymbol Name
n) = Name
n
interpSymbolName (IBytesSymbol Name
n) = Name
n

interpretedInterpSymbol :: InterpSymbol Interpreted -> FastString
interpretedInterpSymbol :: InterpSymbol 'Interpreted -> FastString
interpretedInterpSymbol (IFaststringSymbol FastString
s) = FastString
s

interpSymbolSuffix :: InterpSymbol (Suffix s) -> String
interpSymbolSuffix :: forall (s :: Symbol). InterpSymbol ('Suffix s) -> String
interpSymbolSuffix (IClosureSymbol {}) = String
"closure"
interpSymbolSuffix (IConInfoSymbol {}) = String
"con_info"
interpSymbolSuffix (IStaticInfoSymbol {}) = String
"static_info"
interpSymbolSuffix (IBytesSymbol {})      = String
"bytes"

emptySymbolCache :: SymbolCache s
emptySymbolCache :: forall (s :: Symbol). SymbolCache s
emptySymbolCache = UniqFM Name (Ptr ()) -> SymbolCache s
forall (s :: Symbol). UniqFM Name (Ptr ()) -> SymbolCache s
SymbolCache UniqFM Name (Ptr ())
forall {k} (key :: k) elt. UniqFM key elt
emptyUFM

lookupSymbolCache :: InterpSymbol (Suffix s) -> SymbolCache s -> Maybe (Ptr ())
lookupSymbolCache :: forall (s :: Symbol).
InterpSymbol ('Suffix s) -> SymbolCache s -> Maybe (Ptr ())
lookupSymbolCache InterpSymbol ('Suffix s)
s (SymbolCache UniqFM Name (Ptr ())
cache) = UniqFM Name (Ptr ()) -> Name -> Maybe (Ptr ())
forall key elt. Uniquable key => UniqFM key elt -> key -> Maybe elt
lookupUFM UniqFM Name (Ptr ())
cache (InterpSymbol ('Suffix s) -> Name
forall (s :: Symbol). InterpSymbol ('Suffix s) -> Name
interpSymbolName InterpSymbol ('Suffix s)
s)

insertSymbolCache :: InterpSymbol (Suffix s) -> Ptr () -> SymbolCache s -> SymbolCache s
insertSymbolCache :: forall (s :: Symbol).
InterpSymbol ('Suffix s)
-> Ptr () -> SymbolCache s -> SymbolCache s
insertSymbolCache InterpSymbol ('Suffix s)
s Ptr ()
v (SymbolCache UniqFM Name (Ptr ())
cache) = UniqFM Name (Ptr ()) -> SymbolCache s
forall (s :: Symbol). UniqFM Name (Ptr ()) -> SymbolCache s
SymbolCache (UniqFM Name (Ptr ()) -> Name -> Ptr () -> UniqFM Name (Ptr ())
forall key elt.
Uniquable key =>
UniqFM key elt -> key -> elt -> UniqFM key elt
addToUFM UniqFM Name (Ptr ())
cache (InterpSymbol ('Suffix s) -> Name
forall (s :: Symbol). InterpSymbol ('Suffix s) -> Name
interpSymbolName InterpSymbol ('Suffix s)
s) Ptr ()
v)

lookupInterpSymbolCache :: InterpSymbol s -> InterpSymbolCache -> IO (Maybe (Ptr ()))
lookupInterpSymbolCache :: forall (s :: SuffixOrInterpreted).
InterpSymbol s -> InterpSymbolCache -> IO (Maybe (Ptr ()))
lookupInterpSymbolCache = (InterpSymbol 'Interpreted
 -> MVar (UniqFM FastString (Ptr ())) -> IO (Maybe (Ptr ())))
-> (forall (x :: Symbol).
    InterpSymbol ('Suffix x)
    -> MVar (SymbolCache x) -> IO (Maybe (Ptr ())))
-> InterpSymbol s
-> InterpSymbolCache
-> IO (Maybe (Ptr ()))
forall r (s :: SuffixOrInterpreted).
(InterpSymbol 'Interpreted
 -> MVar (UniqFM FastString (Ptr ())) -> r)
-> (forall (x :: Symbol).
    InterpSymbol ('Suffix x) -> MVar (SymbolCache x) -> r)
-> InterpSymbol s
-> InterpSymbolCache
-> r
withInterpSymbolCache
                            (\(IFaststringSymbol FastString
f) MVar (UniqFM FastString (Ptr ()))
mvar_var -> (\UniqFM FastString (Ptr ())
cache -> UniqFM FastString (Ptr ()) -> FastString -> Maybe (Ptr ())
forall key elt. Uniquable key => UniqFM key elt -> key -> Maybe elt
lookupUFM UniqFM FastString (Ptr ())
cache FastString
f) (UniqFM FastString (Ptr ()) -> Maybe (Ptr ()))
-> IO (UniqFM FastString (Ptr ())) -> IO (Maybe (Ptr ()))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MVar (UniqFM FastString (Ptr ()))
-> IO (UniqFM FastString (Ptr ()))
forall a. MVar a -> IO a
readMVar MVar (UniqFM FastString (Ptr ()))
mvar_var)
                            (\InterpSymbol ('Suffix x)
s MVar (SymbolCache x)
mvar_var -> InterpSymbol ('Suffix x) -> SymbolCache x -> Maybe (Ptr ())
forall (s :: Symbol).
InterpSymbol ('Suffix s) -> SymbolCache s -> Maybe (Ptr ())
lookupSymbolCache InterpSymbol ('Suffix x)
s (SymbolCache x -> Maybe (Ptr ()))
-> IO (SymbolCache x) -> IO (Maybe (Ptr ()))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MVar (SymbolCache x) -> IO (SymbolCache x)
forall a. MVar a -> IO a
readMVar MVar (SymbolCache x)
mvar_var)


updateInterpSymbolCache :: InterpSymbol s
                                 -> InterpSymbolCache -> Ptr () -> IO ()
updateInterpSymbolCache :: forall (s :: SuffixOrInterpreted).
InterpSymbol s -> InterpSymbolCache -> Ptr () -> IO ()
updateInterpSymbolCache = (InterpSymbol 'Interpreted
 -> MVar (UniqFM FastString (Ptr ())) -> Ptr () -> IO ())
-> (forall (x :: Symbol).
    InterpSymbol ('Suffix x)
    -> MVar (SymbolCache x) -> Ptr () -> IO ())
-> InterpSymbol s
-> InterpSymbolCache
-> Ptr ()
-> IO ()
forall r (s :: SuffixOrInterpreted).
(InterpSymbol 'Interpreted
 -> MVar (UniqFM FastString (Ptr ())) -> r)
-> (forall (x :: Symbol).
    InterpSymbol ('Suffix x) -> MVar (SymbolCache x) -> r)
-> InterpSymbol s
-> InterpSymbolCache
-> r
withInterpSymbolCache
                            (\(IFaststringSymbol FastString
f) MVar (UniqFM FastString (Ptr ()))
mvar_var Ptr ()
v -> MVar (UniqFM FastString (Ptr ()))
-> (UniqFM FastString (Ptr ()) -> IO (UniqFM FastString (Ptr ())))
-> IO ()
forall a. MVar a -> (a -> IO a) -> IO ()
modifyMVar_ MVar (UniqFM FastString (Ptr ()))
mvar_var (\UniqFM FastString (Ptr ())
cache -> UniqFM FastString (Ptr ()) -> IO (UniqFM FastString (Ptr ()))
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (UniqFM FastString (Ptr ()) -> IO (UniqFM FastString (Ptr ())))
-> UniqFM FastString (Ptr ()) -> IO (UniqFM FastString (Ptr ()))
forall a b. (a -> b) -> a -> b
$ UniqFM FastString (Ptr ())
-> FastString -> Ptr () -> UniqFM FastString (Ptr ())
forall key elt.
Uniquable key =>
UniqFM key elt -> key -> elt -> UniqFM key elt
addToUFM UniqFM FastString (Ptr ())
cache FastString
f Ptr ()
v))
                            (\InterpSymbol ('Suffix x)
s MVar (SymbolCache x)
mvar_var Ptr ()
v -> MVar (SymbolCache x)
-> (SymbolCache x -> IO (SymbolCache x)) -> IO ()
forall a. MVar a -> (a -> IO a) -> IO ()
modifyMVar_ MVar (SymbolCache x)
mvar_var (\SymbolCache x
cache -> SymbolCache x -> IO (SymbolCache x)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SymbolCache x -> IO (SymbolCache x))
-> SymbolCache x -> IO (SymbolCache x)
forall a b. (a -> b) -> a -> b
$ InterpSymbol ('Suffix x)
-> Ptr () -> SymbolCache x -> SymbolCache x
forall (s :: Symbol).
InterpSymbol ('Suffix s)
-> Ptr () -> SymbolCache s -> SymbolCache s
insertSymbolCache InterpSymbol ('Suffix x)
s Ptr ()
v SymbolCache x
cache))

withInterpSymbolCache ::
                (InterpSymbol Interpreted -> MVar (UniqFM FastString (Ptr ())) -> r)
                -> (forall x . InterpSymbol (Suffix x) -> MVar (SymbolCache x) -> r)
                -> InterpSymbol s
                -> InterpSymbolCache
                -> r
withInterpSymbolCache :: forall r (s :: SuffixOrInterpreted).
(InterpSymbol 'Interpreted
 -> MVar (UniqFM FastString (Ptr ())) -> r)
-> (forall (x :: Symbol).
    InterpSymbol ('Suffix x) -> MVar (SymbolCache x) -> r)
-> InterpSymbol s
-> InterpSymbolCache
-> r
withInterpSymbolCache InterpSymbol 'Interpreted -> MVar (UniqFM FastString (Ptr ())) -> r
k1 forall (x :: Symbol).
InterpSymbol ('Suffix x) -> MVar (SymbolCache x) -> r
k2 InterpSymbol s
key InterpSymbolCache{MVar (UniqFM FastString (Ptr ()))
MVar (SymbolCache "bytes")
MVar (SymbolCache "closure")
MVar (SymbolCache "con_info")
MVar (SymbolCache "static_info")
interpClosureCache :: InterpSymbolCache -> MVar (SymbolCache "closure")
interpConInfoCache :: InterpSymbolCache -> MVar (SymbolCache "con_info")
interpStaticInfoCache :: InterpSymbolCache -> MVar (SymbolCache "static_info")
interpBytesCache :: InterpSymbolCache -> MVar (SymbolCache "bytes")
interpFaststringCache :: InterpSymbolCache -> MVar (UniqFM FastString (Ptr ()))
interpClosureCache :: MVar (SymbolCache "closure")
interpConInfoCache :: MVar (SymbolCache "con_info")
interpStaticInfoCache :: MVar (SymbolCache "static_info")
interpBytesCache :: MVar (SymbolCache "bytes")
interpFaststringCache :: MVar (UniqFM FastString (Ptr ()))
..} =
  case InterpSymbol s
key of
    IClosureSymbol {} -> InterpSymbol ('Suffix "closure")
-> MVar (SymbolCache "closure") -> r
forall (x :: Symbol).
InterpSymbol ('Suffix x) -> MVar (SymbolCache x) -> r
k2 InterpSymbol s
InterpSymbol ('Suffix "closure")
key MVar (SymbolCache "closure")
interpClosureCache
    IConInfoSymbol {} -> InterpSymbol ('Suffix "con_info")
-> MVar (SymbolCache "con_info") -> r
forall (x :: Symbol).
InterpSymbol ('Suffix x) -> MVar (SymbolCache x) -> r
k2 InterpSymbol s
InterpSymbol ('Suffix "con_info")
key MVar (SymbolCache "con_info")
interpConInfoCache
    IStaticInfoSymbol {} -> InterpSymbol ('Suffix "static_info")
-> MVar (SymbolCache "static_info") -> r
forall (x :: Symbol).
InterpSymbol ('Suffix x) -> MVar (SymbolCache x) -> r
k2 InterpSymbol s
InterpSymbol ('Suffix "static_info")
key MVar (SymbolCache "static_info")
interpStaticInfoCache
    IBytesSymbol {} -> InterpSymbol ('Suffix "bytes") -> MVar (SymbolCache "bytes") -> r
forall (x :: Symbol).
InterpSymbol ('Suffix x) -> MVar (SymbolCache x) -> r
k2 InterpSymbol s
InterpSymbol ('Suffix "bytes")
key MVar (SymbolCache "bytes")
interpBytesCache
    IFaststringSymbol {} -> InterpSymbol 'Interpreted -> MVar (UniqFM FastString (Ptr ())) -> r
k1 InterpSymbol s
InterpSymbol 'Interpreted
key MVar (UniqFM FastString (Ptr ()))
interpFaststringCache

-- | Clear all symbol caches.
purgeInterpSymbolCache :: InterpSymbolCache -> IO ()
purgeInterpSymbolCache :: InterpSymbolCache -> IO ()
purgeInterpSymbolCache (InterpSymbolCache MVar (SymbolCache "closure")
a MVar (SymbolCache "con_info")
b MVar (SymbolCache "static_info")
c MVar (SymbolCache "bytes")
d MVar (UniqFM FastString (Ptr ()))
e) = do
  MVar (SymbolCache "closure")
-> (SymbolCache "closure" -> IO (SymbolCache "closure")) -> IO ()
forall a. MVar a -> (a -> IO a) -> IO ()
modifyMVar_ MVar (SymbolCache "closure")
a (\SymbolCache "closure"
_ ->  do
    MVar (SymbolCache "con_info")
-> (SymbolCache "con_info" -> IO (SymbolCache "con_info")) -> IO ()
forall a. MVar a -> (a -> IO a) -> IO ()
modifyMVar_ MVar (SymbolCache "con_info")
b (\SymbolCache "con_info"
_ -> do
      MVar (SymbolCache "static_info")
-> (SymbolCache "static_info" -> IO (SymbolCache "static_info"))
-> IO ()
forall a. MVar a -> (a -> IO a) -> IO ()
modifyMVar_ MVar (SymbolCache "static_info")
c (\SymbolCache "static_info"
_ -> do
        MVar (SymbolCache "bytes")
-> (SymbolCache "bytes" -> IO (SymbolCache "bytes")) -> IO ()
forall a. MVar a -> (a -> IO a) -> IO ()
modifyMVar_ MVar (SymbolCache "bytes")
d (\SymbolCache "bytes"
_ -> do
          MVar (UniqFM FastString (Ptr ()))
-> (UniqFM FastString (Ptr ()) -> IO (UniqFM FastString (Ptr ())))
-> IO ()
forall a. MVar a -> (a -> IO a) -> IO ()
modifyMVar_ MVar (UniqFM FastString (Ptr ()))
e (\UniqFM FastString (Ptr ())
_ -> UniqFM FastString (Ptr ()) -> IO (UniqFM FastString (Ptr ()))
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UniqFM FastString (Ptr ())
forall {k} (key :: k) elt. UniqFM key elt
emptyUFM)
          SymbolCache "bytes" -> IO (SymbolCache "bytes")
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SymbolCache "bytes"
forall (s :: Symbol). SymbolCache s
emptySymbolCache)
        SymbolCache "static_info" -> IO (SymbolCache "static_info")
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SymbolCache "static_info"
forall (s :: Symbol). SymbolCache s
emptySymbolCache)
      SymbolCache "con_info" -> IO (SymbolCache "con_info")
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SymbolCache "con_info"
forall (s :: Symbol). SymbolCache s
emptySymbolCache)
    SymbolCache "closure" -> IO (SymbolCache "closure")
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SymbolCache "closure"
forall (s :: Symbol). SymbolCache s
emptySymbolCache)

mkInterpSymbolCache :: IO InterpSymbolCache
mkInterpSymbolCache :: IO InterpSymbolCache
mkInterpSymbolCache = do
  MVar (SymbolCache "closure")
-> MVar (SymbolCache "con_info")
-> MVar (SymbolCache "static_info")
-> MVar (SymbolCache "bytes")
-> MVar (UniqFM FastString (Ptr ()))
-> InterpSymbolCache
InterpSymbolCache (MVar (SymbolCache "closure")
 -> MVar (SymbolCache "con_info")
 -> MVar (SymbolCache "static_info")
 -> MVar (SymbolCache "bytes")
 -> MVar (UniqFM FastString (Ptr ()))
 -> InterpSymbolCache)
-> IO (MVar (SymbolCache "closure"))
-> IO
     (MVar (SymbolCache "con_info")
      -> MVar (SymbolCache "static_info")
      -> MVar (SymbolCache "bytes")
      -> MVar (UniqFM FastString (Ptr ()))
      -> InterpSymbolCache)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SymbolCache "closure" -> IO (MVar (SymbolCache "closure"))
forall a. a -> IO (MVar a)
newMVar SymbolCache "closure"
forall (s :: Symbol). SymbolCache s
emptySymbolCache
                    IO
  (MVar (SymbolCache "con_info")
   -> MVar (SymbolCache "static_info")
   -> MVar (SymbolCache "bytes")
   -> MVar (UniqFM FastString (Ptr ()))
   -> InterpSymbolCache)
-> IO (MVar (SymbolCache "con_info"))
-> IO
     (MVar (SymbolCache "static_info")
      -> MVar (SymbolCache "bytes")
      -> MVar (UniqFM FastString (Ptr ()))
      -> InterpSymbolCache)
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SymbolCache "con_info" -> IO (MVar (SymbolCache "con_info"))
forall a. a -> IO (MVar a)
newMVar SymbolCache "con_info"
forall (s :: Symbol). SymbolCache s
emptySymbolCache
                    IO
  (MVar (SymbolCache "static_info")
   -> MVar (SymbolCache "bytes")
   -> MVar (UniqFM FastString (Ptr ()))
   -> InterpSymbolCache)
-> IO (MVar (SymbolCache "static_info"))
-> IO
     (MVar (SymbolCache "bytes")
      -> MVar (UniqFM FastString (Ptr ())) -> InterpSymbolCache)
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SymbolCache "static_info" -> IO (MVar (SymbolCache "static_info"))
forall a. a -> IO (MVar a)
newMVar SymbolCache "static_info"
forall (s :: Symbol). SymbolCache s
emptySymbolCache
                    IO
  (MVar (SymbolCache "bytes")
   -> MVar (UniqFM FastString (Ptr ())) -> InterpSymbolCache)
-> IO (MVar (SymbolCache "bytes"))
-> IO (MVar (UniqFM FastString (Ptr ())) -> InterpSymbolCache)
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SymbolCache "bytes" -> IO (MVar (SymbolCache "bytes"))
forall a. a -> IO (MVar a)
newMVar SymbolCache "bytes"
forall (s :: Symbol). SymbolCache s
emptySymbolCache
                    IO (MVar (UniqFM FastString (Ptr ())) -> InterpSymbolCache)
-> IO (MVar (UniqFM FastString (Ptr ()))) -> IO InterpSymbolCache
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> UniqFM FastString (Ptr ())
-> IO (MVar (UniqFM FastString (Ptr ())))
forall a. a -> IO (MVar a)
newMVar UniqFM FastString (Ptr ())
forall {k} (key :: k) elt. UniqFM key elt
emptyUFM