Skip to content

Commit

Permalink
Support GHC-8.8
Browse files Browse the repository at this point in the history
Add MonadFail instances and constraints.
  • Loading branch information
vrom911 authored Feb 26, 2020
1 parent 7b924e7 commit d2ee5b2
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ tags
cabal.sandbox.config
.cabal-sandbox/
.stack-work
dist
dist-*
.ghc.environment.*

# Ignore test builds.
tests/Main
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ title: Releases

# Releases

## Unreleased

- Support GHC-8.8. Add `MonadFail` instances and constraints.

## Hakyll 4.13.0.1 (2019-09-18)

- Add missing test files (contribution by Justin Humm)
Expand Down
10 changes: 5 additions & 5 deletions hakyll.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ Library
lrucache >= 1.1.1 && < 1.3,
mtl >= 1 && < 2.3,
network-uri >= 2.6 && < 2.7,
optparse-applicative >= 0.12 && < 0.15,
optparse-applicative >= 0.12 && < 0.16,
parsec >= 3.0 && < 3.2,
process >= 1.6 && < 1.7,
random >= 1.0 && < 1.2,
regex-tdfa >= 1.1 && < 1.3,
regex-tdfa >= 1.1 && < 1.4,
resourcet >= 1.1 && < 1.3,
scientific >= 0.3.4 && < 0.4,
tagsoup >= 0.13.1 && < 0.15,
template-haskell >= 2.14 && < 2.15,
template-haskell >= 2.14 && < 2.16,
text >= 0.11 && < 1.3,
time >= 1.8 && < 1.10,
time-locale-compat >= 0.1 && < 0.2,
Expand Down Expand Up @@ -231,7 +231,7 @@ Library
Other-Modules:
Hakyll.Web.Pandoc.Binary
Build-Depends:
pandoc >= 2.0.5 && < 2.8,
pandoc >= 2.0.5 && < 2.10,
pandoc-citeproc >= 0.14 && < 0.17
Cpp-options:
-DUSE_PANDOC
Expand Down Expand Up @@ -326,4 +326,4 @@ Executable hakyll-website
base >= 4 && < 5,
directory >= 1.0 && < 1.4,
filepath >= 1.0 && < 1.5,
pandoc >= 2.0.5 && < 2.8
pandoc >= 2.0.5 && < 2.10
8 changes: 7 additions & 1 deletion lib/Hakyll/Core/Compiler/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module Hakyll.Core.Compiler.Internal
import Control.Applicative (Alternative (..))
import Control.Exception (SomeException, handle)
import Control.Monad (forM_)
import qualified Control.Monad.Fail as Fail
import Control.Monad.Except (MonadError (..))
import Data.List.NonEmpty (NonEmpty (..))
import qualified Data.List.NonEmpty as NonEmpty
Expand Down Expand Up @@ -183,9 +184,14 @@ instance Monad Compiler where
CompilerError e -> return $ CompilerError e
{-# INLINE (>>=) #-}

fail = compilerThrow . return
#if !(MIN_VERSION_base(4,13,0))
fail = Fail.fail
{-# INLINE fail #-}
#endif

instance Fail.MonadFail Compiler where
fail = compilerThrow . return
{-# INLINE fail #-}

--------------------------------------------------------------------------------
instance Applicative Compiler where
Expand Down
2 changes: 1 addition & 1 deletion lib/Hakyll/Core/Metadata.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ getMetadataField identifier key = do
--------------------------------------------------------------------------------
-- | Version of 'getMetadataField' which throws an error if the field does not
-- exist.
getMetadataField' :: MonadMetadata m => Identifier -> String -> m String
getMetadataField' :: (MonadFail m, MonadMetadata m) => Identifier -> String -> m String
getMetadataField' identifier key = do
field <- getMetadataField identifier key
case field of
Expand Down
2 changes: 1 addition & 1 deletion lib/Hakyll/Core/Rules/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ emptyRulesState = RulesState Nothing Nothing
-- | The monad used to compose rules
newtype Rules a = Rules
{ unRules :: RWST RulesRead RuleSet RulesState IO a
} deriving (Monad, Functor, Applicative)
} deriving (Monad, MonadFail, Functor, Applicative)


--------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lib/Hakyll/Web/Template/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ dateFieldWith locale key format = field key $ \i -> do
-- | Parser to try to extract and parse the time from the @published@
-- field or from the filename. See 'dateField' for more information.
-- Exported for user convenience.
getItemUTC :: MonadMetadata m
getItemUTC :: (MonadMetadata m, MonadFail m)
=> TimeLocale -- ^ Output time locale
-> Identifier -- ^ Input page
-> m UTCTime -- ^ Parsed UTCTime
Expand Down
8 changes: 4 additions & 4 deletions lib/Hakyll/Web/Template/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ applyJoinTemplateList delimiter tpl context items = do
--------------------------------------------------------------------------------
-- | Sort pages chronologically. Uses the same method as 'dateField' for
-- extracting the date.
chronological :: MonadMetadata m => [Item a] -> m [Item a]
chronological :: (MonadMetadata m, MonadFail m) => [Item a] -> m [Item a]
chronological =
sortByM $ getItemUTC defaultTimeLocale . itemIdentifier
where
Expand All @@ -71,21 +71,21 @@ chronological =

--------------------------------------------------------------------------------
-- | The reverse of 'chronological'
recentFirst :: MonadMetadata m => [Item a] -> m [Item a]
recentFirst :: (MonadMetadata m, MonadFail m) => [Item a] -> m [Item a]
recentFirst = liftM reverse . chronological


--------------------------------------------------------------------------------
-- | Version of 'chronological' which doesn't need the actual items.
sortChronological
:: MonadMetadata m => [Identifier] -> m [Identifier]
:: (MonadMetadata m, MonadFail m) => [Identifier] -> m [Identifier]
sortChronological ids =
liftM (map itemIdentifier) $ chronological [Item i () | i <- ids]


--------------------------------------------------------------------------------
-- | Version of 'recentFirst' which doesn't need the actual items.
sortRecentFirst
:: MonadMetadata m => [Identifier] -> m [Identifier]
:: (MonadMetadata m, MonadFail m) => [Identifier] -> m [Identifier]
sortRecentFirst ids =
liftM (map itemIdentifier) $ recentFirst [Item i () | i <- ids]
12 changes: 3 additions & 9 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-13.29
resolver: lts-15.0
save-hackage-creds: false

flags:
Expand All @@ -23,11 +23,5 @@ build:
haddock-deps: false

extra-deps:
- 'cmark-gfm-0.2.0'
- 'hslua-module-system-0.2.1'
- 'ipynb-0.1'
- 'lrucache-1.2.0.1'
- 'pandoc-2.7.3'
- 'pandoc-citeproc-0.16.2'
- 'skylighting-0.8.2'
- 'skylighting-core-0.8.2'
- 'http2-1.6.5'
- 'warp-3.2.28'

0 comments on commit d2ee5b2

Please sign in to comment.