on master help sign in
Added MonadError's instance for Compiler.
617322aIvan N. Veselov
src/Hakyll/Core/Compiler/Internal.hs+8
@@ -2,6 +2,8 @@
2-- | Internally used compiler module
2-- | Internally used compiler module
3{-# LANGUAGE GADTs #-}
3{-# LANGUAGE GADTs #-}
4{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5+{-# LANGUAGE FlexibleInstances #-}
6+{-# LANGUAGE MultiParamTypeClasses #-}
5module Hakyll.Core.Compiler.Internal
7module Hakyll.Core.Compiler.Internal
6 ( -- * Types
8 ( -- * Types
7 CompilerRead (..)
9 CompilerRead (..)
@@ -29,6 +31,7 @@ import Control.Applicative (Alternative (..),
29 Applicative (..), (<$>))
31 Applicative (..), (<$>))
30import Control.Exception (SomeException, handle)
32import Control.Exception (SomeException, handle)
31import Control.Monad (forM_)
33import Control.Monad (forM_)
34+import Control.Monad.Error
32import Data.Monoid (Monoid (..))
35import Data.Monoid (Monoid (..))
33import Data.Set (Set)
36import Data.Set (Set)
34import qualified Data.Set as S
37import qualified Data.Set as S
@@ -146,6 +149,11 @@ instance MonadMetadata Compiler where
146 getMetadata = compilerGetMetadata
149 getMetadata = compilerGetMetadata
147 getMatches = compilerGetMatches
150 getMatches = compilerGetMatches
148
151
152+--------------------------------------------------------------------------------
153+instance MonadError [String] Compiler where
154+ throwError = compilerThrow
155+ catchError = compilerCatch
156+
149
157
150--------------------------------------------------------------------------------
158--------------------------------------------------------------------------------
151runCompiler :: Compiler a -> CompilerRead -> IO (CompilerResult a)
159runCompiler :: Compiler a -> CompilerRead -> IO (CompilerResult a)