summaryrefslogtreecommitdiff
path: root/ghc/GHCi/Util.hs
blob: 050a0566d6e72f2693567a33a5a0a4357b67df7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{-# LANGUAGE MagicHash, UnboxedTuples #-}

-- | Utilities for GHCi.
module GHCi.Util where

-- NOTE: Avoid importing GHC modules here, because the primary purpose
-- of this module is to not use UnboxedTuples in a module that imports
-- lots of other modules.  See issue#13101 for more info.

import GHC.Exts
import GHC.Types

anyToPtr :: a -> IO (Ptr ())
anyToPtr x =
  IO (\s -> case anyToAddr# x s of
              (# s', addr #) -> (# s', Ptr addr #)) :: IO (Ptr ())