-- | Utilities for constructing and converting 'Source', 'Source' and-- 'BSource' types. Please see "Data.Conduit.Types.Source" for more information-- on the base types.moduleData.Conduit.Util.Source(sourceState,sourceStateIO,SourceStateResult(..),sourceIO,SourceIOResult(..))whereimportControl.Monad.Trans.ResourceimportData.Conduit.Internal-- | The return value when pulling in the @sourceState@ function. Either-- indicates no more data, or the next value and an updated state.---- Since 0.3.0dataSourceStateResultstateoutput=StateOpenstateoutput|StateClosed-- | Construct a 'Source' with some stateful functions. This function addresses-- threading the state value for you.---- Since 0.3.0sourceState::Monadm=>state-- ^ Initial state->(state->m(SourceStateResultstateoutput))-- ^ Pull function->SourcemoutputsourceStatestate0pull0=srcstate0wheresrcstate=PipeM(pullstate)pullstate=dores<-pull0statereturn$caseresofStateOpenstate'val->HaveOutput(srcstate')(return())valStateClosed->Done()-- | The return value when pulling in the @sourceIO@ function. Either indicates-- no more data, or the next value.---- Since 0.3.0dataSourceIOResultoutput=IOOpenoutput|IOClosed-- | Construct a 'Source' based on some IO actions for alloc/release.---- Since 0.3.0sourceIO::MonadResourcem=>IOstate-- ^ resource and/or state allocation->(state->IO())-- ^ resource and/or state cleanup->(state->m(SourceIOResultoutput))-- ^ Pull function. Note that this should not perform any cleanup.->SourcemoutputsourceIOalloccleanuppull0=PipeM(do(key,state)<-allocatealloccleanuppullkeystate)wheresrckeystate=PipeM(pullkeystate)pullkeystate=dores<-pull0statecaseresofIOClosed->doreleasekeyreturn$Done()IOOpenval->return$HaveOutput(srckeystate)(releasekey)val-- | A combination of 'sourceIO' and 'sourceState'.---- Since 0.3.0sourceStateIO::MonadResourcem=>IOstate-- ^ resource and/or state allocation->(state->IO())-- ^ resource and/or state cleanup->(state->m(SourceStateResultstateoutput))-- ^ Pull function. Note that this need not explicitly perform any cleanup.->SourcemoutputsourceStateIOalloccleanuppull0=PipeM(do(key,state)<-allocatealloccleanuppullkeystate)wheresrckeystate=PipeM(pullkeystate)pullkeystate=dores<-pull0statecaseresofStateClosed->doreleasekeyreturn$Done()StateOpenstate'val->return$HaveOutput(srckeystate')(releasekey)val-- FIXME transPipe