enumerator-tf (empty) → 0.1
raw patch · 4 files changed
+130/−0 lines, 4 filesdep +basedep +enumeratordep +extensible-exceptionssetup-changed
Dependencies added: base, enumerator, extensible-exceptions, monads-tf
Files
- Data/Enumerator/Instances/TF.hs +69/−0
- Setup.hs +2/−0
- enumerator-tf.cabal +37/−0
- license.txt +22/−0
+ Data/Enumerator/Instances/TF.hs view
@@ -0,0 +1,69 @@+{-# LANGUAGE TypeFamilies #-}+-----------------------------------------------------------------------------+-- |+-- Module: Data.Enumerator.Instances.TF+-- Copyright: 2010 John Millikin+-- License: MIT+--+-- Maintainer: jmillikin@gmail.com+-- Portability: portable+--+-- Enumerator instances for monads-tf classes+--+-----------------------------------------------------------------------------+module Data.Enumerator.Instances.TF () where++import qualified Control.Exception as Exc++import Control.Monad.Trans (lift)+import qualified Control.Monad.Cont.Class as M_C+import qualified Control.Monad.Error.Class as M_E+import qualified Control.Monad.RWS.Class as M_RWS+import qualified Control.Monad.Reader.Class as M_R+import qualified Control.Monad.State.Class as M_S+import qualified Control.Monad.Writer.Class as M_W++import qualified Data.Enumerator as E+import Data.Monoid (mempty, mappend)++instance M_C.MonadCont m => M_C.MonadCont (E.Iteratee a m) where+ callCC f = E.Iteratee $ M_C.callCC $ \c -> let+ emptyYield x = E.Yield x (E.Chunks [])+ in E.runIteratee (f (E.Iteratee . c . emptyYield))++instance Monad m => M_E.MonadError (E.Iteratee a m) where+ type M_E.ErrorType (E.Iteratee a m) = Exc.SomeException+ throwError = E.throwError+ catchError = E.catchError++instance M_RWS.MonadRWS m => M_RWS.MonadRWS (E.Iteratee a m)++instance M_R.MonadReader m => M_R.MonadReader (E.Iteratee a m) where+ type M_R.EnvType (E.Iteratee a m) = M_R.EnvType m+ ask = lift M_R.ask+ local f m = E.Iteratee (M_R.local f (E.runIteratee m))++instance M_S.MonadState m => M_S.MonadState (E.Iteratee a m) where+ type M_S.StateType (E.Iteratee a m) = M_S.StateType m+ get = lift M_S.get+ put = lift . M_S.put++instance M_W.MonadWriter m => M_W.MonadWriter (E.Iteratee a m) where+ type M_W.WriterType (E.Iteratee a m) = M_W.WriterType m+ tell = lift . M_W.tell+ + listen = loop mempty where+ loop w0 m = E.Iteratee $ do+ ~(step, w1) <- M_W.listen (E.runIteratee m)+ let w = mappend w0 w1+ return $ case step of+ E.Yield x cs -> E.Yield (x, w) cs+ E.Error err -> E.Error err+ E.Continue k -> E.Continue (loop w . k)+ + pass m = E.Iteratee $ M_W.pass $ do+ step <- E.runIteratee m+ case step of+ E.Yield (x, wf) cs -> return (E.Yield x cs, wf)+ E.Error err -> return (E.Error err, id)+ E.Continue k -> return (E.Continue (M_W.pass . k), id)
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ enumerator-tf.cabal view
@@ -0,0 +1,37 @@+name: enumerator-tf+version: 0.1+synopsis: Enumerator instances for monads-tf classes+license: MIT+license-file: license.txt+author: John Millikin <jmillikin@gmail.com>+maintainer: jmillikin@gmail.com+copyright: Copyright (c) John Millikin 2010+build-type: Simple+cabal-version: >=1.6+category: Enumerator+stability: experimental+homepage: http://john-millikin.com/software/enumerator/+bug-reports: mailto:jmillikin@gmail.com+tested-with: GHC==6.12.1++source-repository head+ type: bazaar+ location: http://john-millikin.com/software/enumerator/++library+ ghc-options: -Wall -fno-warn-orphans++ build-depends:+ monads-tf >= 0.1 && < 0.2+ , enumerator >= 0.4 && < 0.5++ if impl(ghc >= 6.10)+ build-depends:+ base >= 4 && < 5+ else+ build-depends:+ base >= 3 && < 4+ , extensible-exceptions >= 0.1 && < 0.2++ exposed-modules:+ Data.Enumerator.Instances.TF
+ license.txt view
@@ -0,0 +1,22 @@+Copyright (c) 2010 John Millikin++Permission is hereby granted, free of charge, to any person+obtaining a copy of this software and associated documentation+files (the "Software"), to deal in the Software without+restriction, including without limitation the rights to use,+copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the+Software is furnished to do so, subject to the following+conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.