mirror of
https://github.com/haskell-effectful/effectful.git
synced 2024-11-30 03:20:03 +03:00
Add a few INLINE pragmas for better performance
This commit is contained in:
parent
67c1a67037
commit
7975895c8c
@ -444,6 +444,7 @@ getLocation (Env fork ref _) = do
|
||||
|
||||
ix :: Int -> Int
|
||||
ix n = n - reifyIndex @e @es - 1
|
||||
{-# INLINE getLocation #-}
|
||||
|
||||
toAny :: a -> Any
|
||||
toAny = unsafeCoerce
|
||||
|
@ -160,24 +160,30 @@ execEffect e0 (Eff m) = unsafeEff $ \es0 -> do
|
||||
|
||||
getEffect :: e :> es => Eff es (i e)
|
||||
getEffect = unsafeEff $ \es -> getEnv es
|
||||
{-# INLINE getEffect #-}
|
||||
|
||||
putEffect :: e :> es => i e -> Eff es ()
|
||||
putEffect e = unsafeEff $ \es -> unsafePutEnv e es
|
||||
{-# INLINE putEffect #-}
|
||||
|
||||
stateEffect :: e :> es => (i e -> (a, i e)) -> Eff es a
|
||||
stateEffect f = unsafeEff $ \es -> unsafeStateEnv f es
|
||||
{-# INLINE stateEffect #-}
|
||||
|
||||
localEffect :: e :> es => (i e -> i e) -> Eff es a -> Eff es a
|
||||
localEffect f (Eff m) = unsafeEff $ \es -> do
|
||||
bracket (unsafeStateEnv (\e -> (e, f e)) es)
|
||||
(\e -> unsafePutEnv e es)
|
||||
(\_ -> m es)
|
||||
{-# INLINE localEffect #-}
|
||||
|
||||
readerEffectM :: e :> es => (i e -> Eff es a) -> Eff es a
|
||||
readerEffectM f = unsafeEff $ \es -> getEnv es >>= \e -> unEff (f e) es
|
||||
{-# INLINE readerEffectM #-}
|
||||
|
||||
stateEffectM :: e :> es => (i e -> Eff es (a, i e)) -> Eff es a
|
||||
stateEffectM f = unsafeEff $ \es -> do
|
||||
(a, e) <- (\e -> unEff (f e) es) =<< getEnv es
|
||||
unsafePutEnv e es
|
||||
pure a
|
||||
{-# INLINE stateEffectM #-}
|
||||
|
Loading…
Reference in New Issue
Block a user