@@ -39,7 +39,7 @@ import Data.Monoid (class Monoid, mempty)
39
39
import Data.Newtype (class Newtype )
40
40
import Data.Time.Duration (Milliseconds (..))
41
41
import Partial.Unsafe (unsafeCrashWith )
42
- import Type.Row.Effect.Equality (class EffectRowEquals , effTo )
42
+ import Type.Row.Effect.Equality (class EffectRowEquals )
43
43
import Unsafe.Coerce (unsafeCoerce )
44
44
45
45
foreign import data Aff ∷ # Effect → Type → Type
@@ -100,7 +100,10 @@ instance monadErrorAff ∷ MonadError Error (Aff eff) where
100
100
Right r → pure r
101
101
102
102
instance monadEffAff ∷ EffectRowEquals eff1 (exception ∷ EXCEPTION , async ∷ ASYNC | eff2 ) ⇒ MonadEff eff1 (Aff eff2 ) where
103
- liftEff eff = Fn .runFn3 _liftEff Left Right (effTo eff)
103
+ liftEff eff = unsafeLiftEff (coerceEff eff)
104
+ where
105
+ coerceEff ∷ Eff eff1 ~> Eff eff2
106
+ coerceEff = unsafeCoerce
104
107
105
108
newtype ParAff eff a = ParAff (Aff eff a )
106
109
@@ -116,7 +119,7 @@ instance applyParAff ∷ Apply (ParAff eff) where
116
119
Thread t3 ← unsafeLaunchAff do
117
120
f ← attempt t1.join
118
121
a ← attempt t2.join
119
- unsafeLiftEff (Right <$> k (f <*> a))
122
+ unsafeLiftEff (k (f <*> a))
120
123
pure $ Canceler \err →
121
124
parSequence_
122
125
[ t3.kill err
@@ -142,18 +145,15 @@ instance altParAff ∷ Alt (ParAff eff) where
142
145
Thread t2 ← unsafeLaunchAff a2
143
146
144
147
let
145
- lift ∷ ∀ a . Eff eff a → Aff eff a
146
- lift = unsafeLiftEff <<< map Right
147
-
148
148
earlyError =
149
149
error " Alt ParAff: early exit"
150
150
151
151
runK t r = do
152
- res ← lift $ unsafeRunRef $ readRef ref
152
+ res ← unsafeLiftEff $ unsafeRunRef $ readRef ref
153
153
case res, r of
154
- Nothing , Left _ → lift $ unsafeRunRef $ writeRef ref (Just r)
155
- Nothing , Right _ → t.kill earlyError *> lift (k r)
156
- Just r', _ → t.kill earlyError *> lift (k r')
154
+ Nothing , Left _ → unsafeLiftEff $ unsafeRunRef $ writeRef ref (Just r)
155
+ Nothing , Right _ → t.kill earlyError *> unsafeLiftEff (k r)
156
+ Just r', _ → t.kill earlyError *> unsafeLiftEff (k r')
157
157
158
158
Thread t3 ← unsafeLaunchAff $ runK t2 =<< attempt t1.join
159
159
Thread t4 ← unsafeLaunchAff $ runK t1 =<< attempt t2.join
@@ -216,17 +216,9 @@ foreign import _bind ∷ ∀ eff a b. Aff eff a → (a → Aff eff b) → Aff ef
216
216
foreign import _delay ∷ ∀ a eff . Fn.Fn2 (Unit → Either a Unit ) Number (Aff eff Unit )
217
217
foreign import attempt ∷ ∀ eff a . Aff eff a → Aff eff (Either Error a )
218
218
foreign import bracket ∷ ∀ eff a b . Aff eff a → (a → Aff eff Unit ) → (a → Aff eff b ) → Aff eff b
219
- foreign import unsafeLiftEff ∷ ∀ eff a . Eff eff ( Either Error a ) → Aff eff a
219
+ foreign import unsafeLiftEff ∷ ∀ eff a . Eff eff a → Aff eff a
220
220
foreign import unsafeMakeAff ∷ ∀ eff a . ((Either Error a → Eff eff Unit ) → Eff eff (Canceler eff )) → Aff eff a
221
221
222
- foreign import _liftEff
223
- ∷ ∀ eff a
224
- . Fn.Fn3
225
- (Error → Either Error a )
226
- (a → Either Error a )
227
- (Eff (AffModality eff ) a )
228
- (Aff eff a )
229
-
230
222
foreign import _makeAff
231
223
∷ ∀ eff a
232
224
. Fn.Fn3
0 commit comments