on master help sign in
Don't use seqUnliftEff when it's not necessary
commitc85a3bb366a32ddafe0372b41ee3a0b921b32ba3 authorAndrzej Rybczak <andrzej@rybczak.net> dateSat 27 Nov 2021, 15:08 (5 years ago) parent8343e2e
4 files changed+8−19
effectful/src/Effectful/Environment.hs+2−6 effectful/src/Effectful/Process.hs+1−2 effectful/src/Effectful/Temporary.hs+4−8 effectful/src/Effectful/Timeout.hs+1−3
effectful/src/Effectful/Environment.hs+2−6
@@ -64,12 +64,8 @@ unsetEnv = unsafeEff_ . E.unsetEnv
6464
6565-- | Lifted 'E.withArgs'.
6666withArgs :: Environment :> es => [String] -> Eff es a -> Eff es a
67−withArgs env k = unsafeEff $ \es -> do
68− seqUnliftEff es $ \runInIO -> do
69− E.withArgs env (runInIO k)
67+withArgs = unsafeLiftMapIO . E.withArgs
7068
7169-- | Lifted 'E.withProgName'.
7270withProgName :: Environment :> es => String -> Eff es a -> Eff es a
73−withProgName n k = unsafeEff $ \es -> do
74− seqUnliftEff es $ \runInIO -> do
75− E.withProgName n (runInIO k)
71+withProgName = unsafeLiftMapIO . E.withProgName
effectful/src/Effectful/Process.hs+1−2
@@ -130,8 +130,7 @@ withCreateProcess
130130 -> (Maybe Handle -> Maybe Handle -> Maybe Handle -> P.ProcessHandle -> Eff es a)
131131 -> Eff es a
132132withCreateProcess cp cb = unsafeEff $ \es -> do
133− seqUnliftEff es $ \runInIO -> do
134− P.withCreateProcess cp (\inh outh errh ph -> runInIO $ cb inh outh errh ph)
133+ P.withCreateProcess cp $ \inh outh errh ph -> unEff (cb inh outh errh ph) es
135134
136135-- | Lifted 'P.cleanupProcess'.
137136cleanupProcess
effectful/src/Effectful/Temporary.hs+4−8
@@ -30,8 +30,7 @@ withSystemTempFile
3030 -- ^ Callback that can use the file.
3131 -> Eff es a
3232withSystemTempFile template action = unsafeEff $ \es -> do
33− seqUnliftEff es $ \unlift -> do
34− T.withSystemTempFile template $ \fp handle -> unlift (action fp handle)
33+ T.withSystemTempFile template $ \fp handle -> unEff (action fp handle) es
3534
3635-- | Lifted 'T.withSystemTempDirectory'.
3736withSystemTempDirectory
@@ -42,8 +41,7 @@ withSystemTempDirectory
4241 -- ^ Callback that can use the directory.
4342 -> Eff es a
4443withSystemTempDirectory template action = unsafeEff $ \es -> do
45− seqUnliftEff es $ \unlift -> do
46− T.withSystemTempDirectory template $ \fp -> unlift (action fp)
44+ T.withSystemTempDirectory template $ \fp -> unEff (action fp) es
4745
4846-- | Lifted 'T.withTempFile'.
4947withTempFile
@@ -56,8 +54,7 @@ withTempFile
5654 -- ^ Callback that can use the file.
5755 -> Eff es a
5856withTempFile tmpDir template action = unsafeEff $ \es -> do
59− seqUnliftEff es $ \unlift -> do
60− T.withTempFile tmpDir template $ \fp handle -> unlift (action fp handle)
57+ T.withTempFile tmpDir template $ \fp handle -> unEff (action fp handle) es
6158
6259-- | Lifted 'T.withTempDirectory'.
6360withTempDirectory
@@ -70,5 +67,4 @@ withTempDirectory
7067 -- ^ Callback that can use the directory.
7168 -> Eff es a
7269withTempDirectory tmpDir template action = unsafeEff $ \es -> do
73− seqUnliftEff es $ \unlift -> do
74− T.withTempDirectory tmpDir template $ \fp -> unlift (action fp)
70+ T.withTempDirectory tmpDir template $ \fp -> unEff (action fp) es
effectful/src/Effectful/Timeout.hs+1−3
@@ -25,6 +25,4 @@ timeout
2525 -> Eff es a
2626 -- ^ The computation the timeout applies to.
2727 -> Eff es (Maybe a)
28−timeout n k = unsafeEff $ \es -> do
29− seqUnliftEff es $ \unlift -> do
30− T.timeout n $ unlift k
28+timeout = unsafeLiftMapIO . T.timeout