{-# LANGUAGE RankNTypes, BangPatterns #-}moduleData.SouSiT.Source(Source,transfer,SimpleSource(..),FeedSource(..),($$),-- * utility functionsconcatSources,concatSources',(=+=),(=+|=),-- * source constructionactionSource,bracketActionSource)whereimportData.SouSiT.SinkimportControl.Exception(bracket)-- | Something that produces data to be processed by a sinkclassSourcesrcwheretransfer::Monadm=>srcma->Sinkamr->mr-- | Transfer the data from the source into the sink($$)::(Sourcesrc,Monadm)=>srcma->Sinkamr->mr($$)=transferinfixl0$$-- | A basic instance of SourcedataSimpleSourcema=SimpleSource(forallr.Sinkamr->mr)instanceSourceSimpleSourcewheretransfer(SimpleSourcef)=f-- | A basic instance of FeedSource (and Source)dataFeedSourcema=FeedSource{feedToSink::forallr.Sinkamr->m(Sinkamr)}instanceSourceFeedSourcewheretransfersrcsink=feedToSinksrcsink>>=closeSink-- | Concatenates two sources.concatSources::(Sourcesrc2,Monadm)=>FeedSourcema->src2ma->SimpleSourcemaconcatSourcessrc1src2=SimpleSourcefwherefsink=feedToSinksrc1sink>>=transfersrc2-- | Concatenates two sources yielding a FeedSource.concatSources'::Monadm=>FeedSourcema->FeedSourcema->FeedSourcemaconcatSources'src1src2=FeedSourcefwherefsink=feedToSinksrc1sink>>=feedToSinksrc2-- | Concatenates two sources.(=+=)::Monadm=>FeedSourcema->FeedSourcema->FeedSourcema(=+=)=concatSources'infixl3=+=-- | Concatenates two sources.(=+|=)::(Sourcesrc2,Monadm)=>FeedSourcema->src2ma->SimpleSourcema(=+|=)=concatSourcesinfixl3=+|=-- | Source that executes a monadic action to get its inputs. Terminates when the sink terminates-- or the action returns Nothing.actionSource::Monadm=>m(Maybei)->FeedSourcemiactionSourcef=FeedSource(handleActionSourcef)-- | Source that first opens a resource, then transfers itself to the sink and the closes the-- resource again (in a bracket).bracketActionSource::IOa->(a->IO())->(a->IO(Maybei))->FeedSourceIOibracketActionSourceopenclosef=FeedSourcehandlewherehandlesink=bracketopenclosestepwherestepa=handleActionSource(fa)sinkhandleActionSource::Monadm=>m(Maybei)->Sinkimr->m(Sinkimr)handleActionSourcef!sink=sinkStatussink>>=handleStatuswherehandleStatus(Done_)=returnsinkhandleStatus(Contnf_)=f>>=handleInputnfhandleInput_Nothing=returnsinkhandleInputnf(Justi)=nfi>>=handleActionSourcef