on master help sign in
Don't use seqUnliftEff when it's not necessary
c85a3bbAndrzej Rybczak
effectful/src/Effectful/Environment.hs+2−6
@@ -64,12 +64,8 @@ unsetEnv = unsafeEff_ . E.unsetEnv
64
64
65-- | Lifted 'E.withArgs'.
65-- | Lifted 'E.withArgs'.
66withArgs :: Environment :> es => [String] -> Eff es a -> Eff es a
66withArgs :: Environment :> es => [String] -> Eff es a -> Eff es a
67−withArgs env k = unsafeEff $ \es -> do
67+withArgs = unsafeLiftMapIO . E.withArgs
68− seqUnliftEff es $ \runInIO -> do
69− E.withArgs env (runInIO k)
70
68
71-- | Lifted 'E.withProgName'.
69-- | Lifted 'E.withProgName'.
72withProgName :: Environment :> es => String -> Eff es a -> Eff es a
70withProgName :: 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
130 -> (Maybe Handle -> Maybe Handle -> Maybe Handle -> P.ProcessHandle -> Eff es a)
130 -> (Maybe Handle -> Maybe Handle -> Maybe Handle -> P.ProcessHandle -> Eff es a)
131 -> Eff es a
131 -> Eff es a
132withCreateProcess cp cb = unsafeEff $ \es -> do
132withCreateProcess 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
135
134
136-- | Lifted 'P.cleanupProcess'.
135-- | Lifted 'P.cleanupProcess'.
137cleanupProcess
136cleanupProcess
effectful/src/Effectful/Temporary.hs+4−8
@@ -30,8 +30,7 @@ withSystemTempFile
30 -- ^ Callback that can use the file.
30 -- ^ Callback that can use the file.
31 -> Eff es a
31 -> Eff es a
32withSystemTempFile template action = unsafeEff $ \es -> do
32withSystemTempFile 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
35
34
36-- | Lifted 'T.withSystemTempDirectory'.
35-- | Lifted 'T.withSystemTempDirectory'.
37withSystemTempDirectory
36withSystemTempDirectory
@@ -42,8 +41,7 @@ withSystemTempDirectory
42 -- ^ Callback that can use the directory.
41 -- ^ Callback that can use the directory.
43 -> Eff es a
42 -> Eff es a
44withSystemTempDirectory template action = unsafeEff $ \es -> do
43withSystemTempDirectory 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
47
45
48-- | Lifted 'T.withTempFile'.
46-- | Lifted 'T.withTempFile'.
49withTempFile
47withTempFile
@@ -56,8 +54,7 @@ withTempFile
56 -- ^ Callback that can use the file.
54 -- ^ Callback that can use the file.
57 -> Eff es a
55 -> Eff es a
58withTempFile tmpDir template action = unsafeEff $ \es -> do
56withTempFile 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
61
58
62-- | Lifted 'T.withTempDirectory'.
59-- | Lifted 'T.withTempDirectory'.
63withTempDirectory
60withTempDirectory
@@ -70,5 +67,4 @@ withTempDirectory
70 -- ^ Callback that can use the directory.
67 -- ^ Callback that can use the directory.
71 -> Eff es a
68 -> Eff es a
72withTempDirectory tmpDir template action = unsafeEff $ \es -> do
69withTempDirectory 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
25 -> Eff es a
25 -> Eff es a
26 -- ^ The computation the timeout applies to.
26 -- ^ The computation the timeout applies to.
27 -> Eff es (Maybe a)
27 -> Eff es (Maybe a)
28−timeout n k = unsafeEff $ \es -> do
28+timeout = unsafeLiftMapIO . T.timeout
29− seqUnliftEff es $ \unlift -> do
30− T.timeout n $ unlift k