----------------------------------------------------------------------------
-- |
-- Module      :  Data.Emacs.Module.SymbolName.Predefined.Funcall
-- Copyright   :  (c) Sergey Vinokurov 2022
-- License     :  Apache-2.0 (see LICENSE)
-- Maintainer  :  serg.foo@gmail.com
----------------------------------------------------------------------------

{-# LANGUAGE DataKinds #-}

module Data.Emacs.Module.SymbolName.Predefined.Funcall
  ( funcall
  ) where

import Data.IORef
import System.IO.Unsafe

import Data.Emacs.Module.Raw.Env.Internal
import Data.Emacs.Module.Raw.Value

import {-# SOURCE #-} Data.Emacs.Module.SymbolName.Internal

funcallSym :: SymbolName
funcallSym :: SymbolName
funcallSym = String -> SymbolName
mkSymbolNameString String
"funcall"

{-# NOINLINE funcallCache #-}
funcallCache :: IORef (Env -> IO (RawValue 'Pinned))
funcallCache :: IORef (Env -> IO (RawValue 'Pinned))
funcallCache = IO (IORef (Env -> IO (RawValue 'Pinned)))
-> IORef (Env -> IO (RawValue 'Pinned))
forall a. IO a -> a
unsafePerformIO (IO (IORef (Env -> IO (RawValue 'Pinned)))
 -> IORef (Env -> IO (RawValue 'Pinned)))
-> IO (IORef (Env -> IO (RawValue 'Pinned)))
-> IORef (Env -> IO (RawValue 'Pinned))
forall a b. (a -> b) -> a -> b
$ SymbolName -> IO (IORef (Env -> IO (RawValue 'Pinned)))
mkSymbolNameCache SymbolName
funcallSym

funcall :: SymbolName
funcall :: SymbolName
funcall = IORef (Env -> IO (RawValue 'Pinned)) -> SymbolName -> SymbolName
mkCachedSymbolName IORef (Env -> IO (RawValue 'Pinned))
funcallCache SymbolName
funcallSym