ghc-mtl (empty) → 1.0.0.0
raw patch · 4 files changed
+137/−0 lines, 4 filesdep +MonadCatchIO-mtldep +basedep +ghcsetup-changed
Dependencies added: MonadCatchIO-mtl, base, ghc, mtl
Files
- Control/Monad/Ghc.hs +79/−0
- LICENSE +27/−0
- Setup.lhs +5/−0
- ghc-mtl.cabal +26/−0
+ Control/Monad/Ghc.hs view
@@ -0,0 +1,79 @@+module Control.Monad.Ghc ( Ghc, runGhc,+ GhcT, runGhcT,+ GHC.GhcMonad(..),+ module Control.Monad.Trans )++where++import Prelude hiding ( catch )++import Control.Monad.Trans+import qualified Control.Monad.Trans as MTL+import Control.Monad.CatchIO++import qualified GHC ( runGhc, runGhcT )+import qualified HscTypes as GHC+import qualified MonadUtils as GHC+import qualified Exception as GHC++newtype Ghc a = Ghc (GHC.Ghc a)+ deriving (Functor, Monad,+ GHC.WarnLogMonad, GHC.ExceptionMonad, GHC.MonadIO, GHC.GhcMonad)++instance MTL.MonadIO Ghc where+ liftIO = GHC.liftIO++instance MonadCatchIO Ghc where+ catch = GHC.gcatch+ block = GHC.gblock+ unblock = GHC.gunblock++runGhc :: Maybe FilePath -> Ghc a -> IO a+runGhc f (Ghc m) = GHC.runGhc f m++newtype GhcT m a = GhcT { unGhcT :: GHC.GhcT (MTLAdapter m) a }+ deriving (Functor, Monad)++runGhcT :: (Functor m, MonadCatchIO m) => Maybe FilePath -> GhcT m a -> m a+runGhcT f = unWrap . GHC.runGhcT f . unGhcT++instance MTL.MonadTrans GhcT where+ lift = GhcT . GHC.liftGhcT . MTLAdapter++instance MTL.MonadIO m => MTL.MonadIO (GhcT m) where+ liftIO = GhcT . GHC.liftIO++instance MTL.MonadIO m => GHC.MonadIO (GhcT m) where+ liftIO = MTL.liftIO++instance MonadCatchIO m => MonadCatchIO (GhcT m) where+ m `catch` f = GhcT $ (unGhcT m) `GHC.gcatch` (unGhcT . f)+ block = GhcT . GHC.gblock . unGhcT+ unblock = GhcT . GHC.gunblock . unGhcT++instance MonadCatchIO m => GHC.ExceptionMonad (GhcT m) where+ gcatch = catch+ gblock = block+ gunblock = unblock++instance MTL.MonadIO m => GHC.WarnLogMonad (GhcT m) where+ setWarnings = GhcT . GHC.setWarnings+ getWarnings = GhcT GHC.getWarnings++instance (Functor m, MonadCatchIO m) => GHC.GhcMonad (GhcT m) where+ getSession = GhcT GHC.getSession+ setSession = GhcT . GHC.setSession++-- | We use the 'MTLAdapter' to convert between similar classes+-- like 'MTL'''s 'MonadIO' and 'GHC'''s 'MonadIO'.+newtype MTLAdapter m a = MTLAdapter {unWrap :: m a} deriving (Functor, Monad)+++instance MTL.MonadIO m => GHC.MonadIO (MTLAdapter m) where+ liftIO = MTLAdapter . MTL.liftIO++instance MonadCatchIO m => GHC.ExceptionMonad (MTLAdapter m) where+ m `gcatch` f = MTLAdapter $ (unWrap m) `catch` (unWrap . f)+ gblock = MTLAdapter. block . unWrap+ gunblock = MTLAdapter. unblock . unWrap+
+ LICENSE view
@@ -0,0 +1,27 @@+Copyright 2007, Daniel Gorin. All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice,+ this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.++3. Neither the name of the author nor the names of its contributors may be+ used to endorse or promote products derived from this software without+ specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+POSSIBILITY OF SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,5 @@+#!/usr/bin/env runhaskell+> module Main where+> import Distribution.Simple+> main :: IO ()+> main = defaultMainWithHooks simpleUserHooks
+ ghc-mtl.cabal view
@@ -0,0 +1,26 @@+name: ghc-mtl+version: 1.0.0.0+description: Provides an 'mtl' compatible version of the 'GhcT'+ monad-transformer defined in the 'GHC-API' since version+ 6.10.1.+synopsis: An mtl compatible version of the Ghc-Api monads+ and monad-transformers.+category: Development+license: BSD3+license-file: LICENSE+author: Daniel Gorin+maintainer: jcpetruzza@gmail.com+homepage: http://code.haskell.org/~jcpetruzza/ghc-mtl++cabal-version: >= 1.2+build-type: Simple+tested-with: GHC==6.10++Library+ build-depends: base >= 4,+ ghc >= 6.10,+ mtl,+ MonadCatchIO-mtl+ exposed-modules: Control.Monad.Ghc+ extensions: GeneralizedNewtypeDeriving+ ghc-options: -Wall -O2