emacs-module-0.2: Utilities to write Emacs dynamic modules
Copyright(c) Sergey Vinokurov 2022
LicenseApache-2.0 (see LICENSE)
Maintainerserg.foo@gmail.com
Safe HaskellSafe-Inferred
LanguageGHC2021

Emacs.Module.Monad

Description

 
Synopsis

Documentation

data EmacsM (s :: k) (a :: Type) Source #

Concrete monad for interacting with Emacs. It provides:

  1. Ability to call Emacs C functions and automatically rethrows any errors (non-local exits) from elisp as Haskell exceptions.
  2. Tracks ownership of any produced Emacs values and communicates that to Emacs, so that GC on Emacs side will not make any values in Haskell invalid (funnily enough, this can happen!).

Parameter s serves to make ownership-tracking capabilities possible. It's use is the same as in ST monad. That is, it creates local threads so that no produced Emacs values can leave past runEmacsM.

Instances

Instances details
MonadEmacs (EmacsM :: k -> Type -> TYPE LiftedRep) (Value :: k -> TYPE LiftedRep) Source # 
Instance details

Defined in Emacs.Module.Monad

Methods

makeGlobalRef :: forall (s :: k0). WithCallStack => Value s -> EmacsM s (RawValue 'Pinned) Source #

freeGlobalRef :: forall (s :: k0). WithCallStack => RawValue 'Pinned -> EmacsM s () Source #

nonLocalExitCheck :: forall (s :: k0). WithCallStack => EmacsM s (FuncallExit ()) Source #

nonLocalExitGet :: forall (s :: k0). WithCallStack => EmacsM s (FuncallExit (Value s, Value s)) Source #

nonLocalExitSignal :: forall f (s :: k0). (WithCallStack, Foldable f) => Value s -> f (Value s) -> EmacsM s () Source #

nonLocalExitThrow :: forall (s :: k0). WithCallStack => Value s -> Value s -> EmacsM s () Source #

nonLocalExitClear :: forall (s :: k0). WithCallStack => EmacsM s () Source #

makeFunction :: forall (req :: Nat) (opt :: Nat) (rest :: Bool) (s :: k0). (WithCallStack, EmacsInvocation req opt rest, GetArities req opt rest) => (forall (s' :: k0). EmacsFunction req opt rest EmacsM Value s') -> Doc -> EmacsM s (Value s) Source #

funcall :: forall f (s :: k0). (WithCallStack, Foldable f) => Value s -> f (Value s) -> EmacsM s (Value s) Source #

funcallPrimitive :: forall f (s :: k0). (WithCallStack, Foldable f) => Value s -> f (Value s) -> EmacsM s (Value s) Source #

funcallPrimitiveUnchecked :: forall f (s :: k0). (WithCallStack, Foldable f) => Value s -> f (Value s) -> EmacsM s (Value s) Source #

intern :: forall (s :: k0). WithCallStack => SymbolName -> EmacsM s (Value s) Source #

typeOf :: forall (s :: k0). WithCallStack => Value s -> EmacsM s (Value s) Source #

isNotNil :: forall (s :: k0). WithCallStack => Value s -> EmacsM s Bool Source #

eq :: forall (s :: k0). WithCallStack => Value s -> Value s -> EmacsM s Bool Source #

extractWideInteger :: forall (s :: k0). WithCallStack => Value s -> EmacsM s Int64 Source #

makeWideInteger :: forall (s :: k0). WithCallStack => Int64 -> EmacsM s (Value s) Source #

extractDouble :: forall (s :: k0). WithCallStack => Value s -> EmacsM s Double Source #

makeDouble :: forall (s :: k0). WithCallStack => Double -> EmacsM s (Value s) Source #

extractText :: forall (s :: k0). WithCallStack => Value s -> EmacsM s Text Source #

extractShortByteString :: forall (s :: k0). WithCallStack => Value s -> EmacsM s ShortByteString Source #

makeString :: forall (s :: k0). WithCallStack => ByteString -> EmacsM s (Value s) Source #

extractUserPtr :: forall (s :: k0) a. WithCallStack => Value s -> EmacsM s (Ptr a) Source #

makeUserPtr :: forall a (s :: k0). WithCallStack => FinalizerPtr a -> Ptr a -> EmacsM s (Value s) Source #

assignUserPtr :: forall (s :: k0) a. WithCallStack => Value s -> Ptr a -> EmacsM s () Source #

extractUserPtrFinaliser :: forall (s :: k0) a. WithCallStack => Value s -> EmacsM s (FinalizerPtr a) Source #

assignUserPtrFinaliser :: forall (s :: k0) a. WithCallStack => Value s -> FinalizerPtr a -> EmacsM s () Source #

vecGet :: forall (s :: k0). WithCallStack => Value s -> Int -> EmacsM s (Value s) Source #

unsafeVecGet :: forall (s :: k0). WithCallStack => Value s -> Int -> EmacsM s (Value s) Source #

vecSet :: forall (s :: k0). WithCallStack => Value s -> Int -> Value s -> EmacsM s () Source #

vecSize :: forall (s :: k0). WithCallStack => Value s -> EmacsM s Int Source #

processInput :: forall (s :: k0). WithCallStack => EmacsM s Result Source #

MonadBaseControl IO (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Associated Types

type StM (EmacsM s) a #

Methods

liftBaseWith :: (RunInBase (EmacsM s) IO -> IO a) -> EmacsM s a #

restoreM :: StM (EmacsM s) a -> EmacsM s a #

MonadBase IO (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Methods

liftBase :: IO α -> EmacsM s α #

MonadFix (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Methods

mfix :: (a -> EmacsM s a) -> EmacsM s a #

MonadIO (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Methods

liftIO :: IO a -> EmacsM s a #

Applicative (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Methods

pure :: a -> EmacsM s a #

(<*>) :: EmacsM s (a -> b) -> EmacsM s a -> EmacsM s b #

liftA2 :: (a -> b -> c) -> EmacsM s a -> EmacsM s b -> EmacsM s c #

(*>) :: EmacsM s a -> EmacsM s b -> EmacsM s b #

(<*) :: EmacsM s a -> EmacsM s b -> EmacsM s a #

Functor (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Methods

fmap :: (a -> b) -> EmacsM s a -> EmacsM s b #

(<$) :: a -> EmacsM s b -> EmacsM s a #

Monad (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Methods

(>>=) :: EmacsM s a -> (a -> EmacsM s b) -> EmacsM s b #

(>>) :: EmacsM s a -> EmacsM s b -> EmacsM s b #

return :: a -> EmacsM s a #

MonadCatch (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Methods

catch :: (HasCallStack, Exception e) => EmacsM s a -> (e -> EmacsM s a) -> EmacsM s a #

MonadMask (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Methods

mask :: HasCallStack => ((forall a. EmacsM s a -> EmacsM s a) -> EmacsM s b) -> EmacsM s b #

uninterruptibleMask :: HasCallStack => ((forall a. EmacsM s a -> EmacsM s a) -> EmacsM s b) -> EmacsM s b #

generalBracket :: HasCallStack => EmacsM s a -> (a -> ExitCase b -> EmacsM s c) -> (a -> EmacsM s b) -> EmacsM s (b, c) #

MonadThrow (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Methods

throwM :: (HasCallStack, Exception e) => e -> EmacsM s a #

MonadInterleave (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Methods

unsafeInterleave :: EmacsM s a -> EmacsM s a #

PrimMonad (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

Associated Types

type PrimState (EmacsM s) #

Methods

primitive :: (State# (PrimState (EmacsM s)) -> (# State# (PrimState (EmacsM s)), a #)) -> EmacsM s a #

type PrimState (EmacsM s) Source # 
Instance details

Defined in Emacs.Module.Monad

type PrimState (EmacsM s)
type StM (EmacsM s) a Source # 
Instance details

Defined in Emacs.Module.Monad

type StM (EmacsM s) a

runEmacsM :: WithCallStack => Env -> (forall s. EmacsM s a) -> IO a Source #

Execute emacs interaction session using an environment supplied by Emacs.