enumerator-fd (empty) → 0.1
raw patch · 4 files changed
+129/−0 lines, 4 filesdep +basedep +enumeratordep +extensible-exceptionssetup-changed
Dependencies added: base, enumerator, extensible-exceptions, monads-fd
Files
- Data/Enumerator/Instances/FD.hs +68/−0
- Setup.hs +2/−0
- enumerator-fd.cabal +37/−0
- license.txt +22/−0
+ Data/Enumerator/Instances/FD.hs view
@@ -0,0 +1,68 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE UndecidableInstances #-}+-----------------------------------------------------------------------------+-- |+-- Module: Data.Enumerator.Instances.FD+-- Copyright: 2010 John Millikin+-- License: MIT+--+-- Maintainer: jmillikin@gmail.com+-- Portability: portable+--+-- Enumerator instances for monads-fd classes+--+-----------------------------------------------------------------------------+module Data.Enumerator.Instances.FD () 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 Exc.SomeException (E.Iteratee a m) where+ throwError = E.throwError+ catchError = E.catchError++instance M_RWS.MonadRWS r w s m => M_RWS.MonadRWS r w s (E.Iteratee a m)++instance M_R.MonadReader r m => M_R.MonadReader r (E.Iteratee a m) where+ ask = lift M_R.ask+ local f m = E.Iteratee (M_R.local f (E.runIteratee m))++instance M_S.MonadState s m => M_S.MonadState s (E.Iteratee a m) where+ get = lift M_S.get+ put = lift . M_S.put++instance M_W.MonadWriter w m => M_W.MonadWriter w (E.Iteratee a m) where+ 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-fd.cabal view
@@ -0,0 +1,37 @@+name: enumerator-fd+version: 0.1+synopsis: Enumerator instances for monads-fd 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-fd >= 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.FD
+ 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.