Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce compiler warnings #267

Merged
merged 4 commits into from
Jul 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Control/Monad/Trans/OptionParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import Prelude hiding (fail)

import Control.Monad hiding (fail)
#if MIN_VERSION_base(4,12,0)
import Control.Monad.Fail (MonadFail, fail)
import Control.Monad.Fail (
#if !MIN_VERSION_base(4,13,0)
MonadFail,
#endif
fail)
#else
import Prelude (fail)
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Control/Monad/Trans/State/Persistent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Control.Monad.Trans.State.Persistent where

import Control.Applicative
import Control.Monad
#if MIN_VERSION_base(4,12,0)
#if MIN_VERSION_base(4,12,0) && !MIN_VERSION_base(4,13,0)
import Control.Monad.Fail (MonadFail)
#endif
import Control.Monad.IO.Class
Expand Down
6 changes: 5 additions & 1 deletion src/Control/Monad/Trans/Uncertain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ module Control.Monad.Trans.Uncertain where
import Prelude hiding (fail)

#if MIN_VERSION_base(4,12,0)
import Control.Monad.Fail (MonadFail, fail)
import Control.Monad.Fail (
#if !MIN_VERSION_base(4,13,0)
MonadFail,
#endif
fail)
#else
import Prelude (fail)
#endif
Expand Down
26 changes: 22 additions & 4 deletions src/Language/Haskell/Exts/Location.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE CPP #-}

-- | Easier access to haskell-src-exts's SrcLoc values.
module Language.Haskell.Exts.Location where

Expand All @@ -14,11 +16,23 @@ import Language.Haskell.Exts.Syntax
--
-- The location only indicates the beginning of a range, because that's what
-- haskell-src-exts provides.
type Located a = Writer (Option (Min SrcLoc)) a
type Located a = Writer (
#if MIN_VERSION_base(4,11,0)
Maybe
#else
Option
#endif
(Min SrcLoc)) a

located :: SrcLoc -> Located ()
located srcLoc | srcLoc == noLoc = tell $ Option $ Nothing
| otherwise = tell $ Option $ Just $ Min srcLoc
located srcLoc =
tell $
#if !MIN_VERSION_base(4,11,0)
Option $
#endif
if srcLoc == noLoc
then Nothing
else Just $ Min srcLoc

annotated :: (Annotated ast, SrcInfo si) => ast si -> Located (ast si)
annotated x = do
Expand All @@ -28,4 +42,8 @@ annotated x = do
runLocated :: Located a -> (a, Maybe SrcLoc)
runLocated = go . runWriter
where
go (x, p) = (x, fmap getMin $ getOption $ p)
go (x, p) = (x, fmap getMin $
#if !MIN_VERSION_base(4,11,0)
getOption
#endif
p)
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-17.5
resolver: lts-17.15
packages:
- .
extra-deps: []
4 changes: 4 additions & 0 deletions tests/System/Console/Hawk/TestUtils.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE CPP #-}

-- Copyright 2013 Mario Pastorelli ([email protected]) Samuel Gélineau ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,8 +16,10 @@

module System.Console.Hawk.TestUtils where

#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
( (<$>) )
#endif
import Control.Exception
( bracket_ )
import Data.List
Expand Down