effin 0.2.1.0 → 0.2.1.1
raw patch · 2 files changed
+8/−8 lines, 2 files
Files
- effin.cabal +1/−1
- src/Control/Effect/Coroutine.hs +7/−7
effin.cabal view
@@ -1,5 +1,5 @@ name: effin-version: 0.2.1.0+version: 0.2.1.1 synopsis: A Typeable-free implementation of extensible effects homepage: https://github.com/YellPika/effin license: BSD3
src/Control/Effect/Coroutine.hs view
@@ -24,27 +24,27 @@ IsCoroutine (Coroutine i o) = True IsCoroutine f = False -class MemberEffect Coroutine (Coroutine i o) es => EffectCoroutine i o es -instance MemberEffect Coroutine (Coroutine i o) es => EffectCoroutine i o es +class MemberEffect Coroutine (Coroutine i o) l => EffectCoroutine i o l +instance MemberEffect Coroutine (Coroutine i o) l => EffectCoroutine i o l -- | Suspends the current computation by providing a value -- of type `i` and then waiting for a value of type `o`. -suspend :: EffectCoroutine i o es => i -> Effect es o +suspend :: EffectCoroutine i o l => i -> Effect l o suspend = send . Coroutine id -- | Converts a `Coroutine` effect into an `Iterator`. -runCoroutine :: Effect (Coroutine i o :+ es) a -> Effect es (Iterator i o es a) +runCoroutine :: Effect (Coroutine i o :+ l) a -> Effect l (Iterator i o l a) runCoroutine = eliminate (return . Done) (\(Coroutine f k) -> return (Next f k)) -- | A suspended computation. -data Iterator i o es a +data Iterator i o l a = Done a -- ^ Describes a finished computation. - | Next (o -> Effect es (Iterator i o es a)) i + | Next (o -> Effect l (Iterator i o l a)) i -- ^ Describes a computation that provided a value -- of type `i` and awaits a value of type `o`. -- | Evaluates an iterator by providing it with an input stream. -evalIterator :: Iterator i o es a -> [o] -> Effect es (Iterator i o es a, [i]) +evalIterator :: Iterator i o l a -> [o] -> Effect l (Iterator i o l a, [i]) evalIterator (Next f v) (x:xs) = do i <- f x (r, vs) <- evalIterator i xs