on master help sign in
Corrected some partial functions
commit4ea7eb93ce26e3e32031d1447642921520bfa3f1 authorMichael <michael@snoyman.com> dateFri 9 Dec 2011, 11:27 (15 years ago) parent2de759d
2 files changed+14−16
conduit/Data/Conduit.hs+14−14 conduit/Data/Conduit/List.hs−2
conduit/Data/Conduit.hs+14−14
@@ -74,6 +74,7 @@ instance MonadBaseControl IO m => Monoid (Source m a) where
7474 [] -> do
7575 liftBase $ I.writeIORef istate Nothing
7676 return EOF
77+ Chunks _ -> return stream
7778
7879type SinkInsideData a m b = Stream a -> ResourceT m (SinkResult a b)
7980data SinkInside a m b =
@@ -143,32 +144,31 @@ sinkJoin (Sink msinkI) = Sink $ do
143144 sinkI <- msinkI
144145 case sinkI of
145146 SinkNoData (Sink inner) -> inner
146− SinkData _msink -> do
147− undefined
148− {-
147+ SinkData msink -> do
149148 istate <- liftBase $ I.newIORef Nothing
150− return $ go istate msink
149+ return $ SinkData $ go istate msink
151150 where
152151 go :: MonadBaseControl IO m
153− => I.IORef (Maybe (SinkInside a m b))
152+ => I.IORef (Maybe (SinkInsideData a m b))
154153 -> (Stream a -> ResourceT m (SinkResult a (Sink a m b)))
155− -> Stream a
156− -> ResourceT m (SinkResult a b)
154+ -> SinkInsideData a m b
157155 go istate outer stream = do
158156 state <- liftBase $ I.readIORef istate
159157 case state of
160158 Nothing -> do
161159 SinkResult leftover minner' <- outer stream
162160 case minner' of
163− Just (SinkData minner) -> do
164− inner <- minner
165− liftBase $ I.writeIORef istate $ Just inner
166− if null leftover
167− then return $ SinkResult [] Nothing
168− else go istate outer $ Chunks leftover
161+ Just (Sink msink) -> do
162+ sink <- msink
163+ case sink of
164+ SinkData inner -> do
165+ liftBase $ I.writeIORef istate $ Just inner
166+ if null leftover
167+ then return $ SinkResult [] Nothing
168+ else go istate outer $ Chunks leftover
169+ SinkNoData x -> return $ SinkResult leftover $ Just x
169170 Nothing -> return $ SinkResult leftover Nothing
170171 Just inner -> inner stream
171− -}
172172
173173type Conduit a m b = Stream a -> ResourceT m (ConduitResult a b)
174174
conduit/Data/Conduit/List.hs−2
@@ -37,8 +37,6 @@ fromList l = Source $ do
3737 unSource $ mkSource $ do
3838 l' <- liftBase $ I.atomicModifyIORef il $ \x -> ([], x)
3939 return $ if null l' then EOF else Chunks l'
40− where
41− unSource (Source s) = s
4240
4341take :: MonadBaseControl IO m
4442 => Int