{-# LANGUAGE MagicHash, UnboxedTuples #-}

-- | Utilities for GHCi.
module Clash.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 :: a -> IO (Ptr ())
anyToPtr a
x =
  (State# RealWorld -> (# State# RealWorld, Ptr () #)) -> IO (Ptr ())
forall a. (State# RealWorld -> (# State# RealWorld, a #)) -> IO a
IO (\State# RealWorld
s -> case a -> State# RealWorld -> (# State# RealWorld, Addr# #)
forall a. a -> State# RealWorld -> (# State# RealWorld, Addr# #)
anyToAddr# a
x State# RealWorld
s of
              (# State# RealWorld
s', Addr#
addr #) -> (# State# RealWorld
s', Addr# -> Ptr ()
forall a. Addr# -> Ptr a
Ptr Addr#
addr #)) :: IO (Ptr ())