Skip to content

Commit bfddbe8

Browse files
committed
Remove some re-exports, raise minimum GHC to 8.6, remove unneeded CPP
1 parent ecb525a commit bfddbe8

21 files changed

+198
-296
lines changed

.nvimrc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
" Enable hlint and GHC via Cabal
2+
let g:ale_linters = {'haskell': ['cabal-build']}
3+
" ... only
4+
let g:ale_linters_explicit = 1
5+
" Don't lint until I save
6+
let g:ale_lint_on_text_changed = 'never'
7+
let g:ale_lint_on_insert_leave = 0
8+
let g:ale_lint_on_enter = 0
9+
10+
call ale#Set('haskell_cabal_build_options', '')
11+
12+
function! GetCabalCommand(buffer) abort
13+
let l:flags = ale#Var(a:buffer, 'haskell_cabal_build_options')
14+
return 'cabal new-build ' . l:flags
15+
endfunction
16+
17+
call ale#linter#Define('haskell', {
18+
\ 'name': 'cabal_build',
19+
\ 'aliases': ['cabal-build'],
20+
\ 'output_stream': 'stderr',
21+
\ 'executable': 'cabal',
22+
\ 'command': function('GetCabalCommand'),
23+
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
24+
\})
25+
26+
let g:neoformat_enabled_cabal = []
27+
28+
let g:neoformat_enabled_haskell = []
29+
30+
" Enable automagic autoformatting
31+
augroup fmt
32+
autocmd!
33+
autocmd BufWritePre * undojoin | Neoformat
34+
augroup end

Control/Monad/Cont.hs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,20 @@ to understand and maintain.
5050

5151
module Control.Monad.Cont (
5252
-- * MonadCont class
53-
MonadCont(..),
53+
MonadCont.MonadCont(..),
5454
-- * The Cont monad
55-
Cont,
56-
cont,
57-
runCont,
58-
evalCont,
59-
mapCont,
60-
withCont,
55+
Cont.Cont,
56+
Cont.cont,
57+
Cont.runCont,
58+
Cont.evalCont,
59+
Cont.mapCont,
60+
Cont.withCont,
6161
-- * The ContT monad transformer
62-
ContT(ContT),
63-
runContT,
64-
evalContT,
65-
mapContT,
66-
withContT,
67-
module Control.Monad,
68-
module Control.Monad.Trans,
62+
Cont.ContT(ContT),
63+
Cont.runContT,
64+
Cont.evalContT,
65+
Cont.mapContT,
66+
Cont.withContT,
6967
-- * Example 1: Simple Continuation Usage
7068
-- $simpleContExample
7169

@@ -76,12 +74,8 @@ module Control.Monad.Cont (
7674
-- $ContTExample
7775
) where
7876

79-
import Control.Monad.Cont.Class
80-
81-
import Control.Monad.Trans
82-
import Control.Monad.Trans.Cont
83-
84-
import Control.Monad
77+
import qualified Control.Monad.Cont.Class as MonadCont
78+
import qualified Control.Monad.Trans.Cont as Cont
8579

8680
{- $simpleContExample
8781
Calculating length of a list continuation-style:

Control/Monad/Cont/Class.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{-# LANGUAGE CPP #-}
2+
-- Needed because the CPSed versions of Writer and State are secretly State
3+
-- wrappers, which don't force such constraints, even though they should legally
4+
-- be there.
5+
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
6+
27
{- |
38
Module : Control.Monad.Cont.Class
49
Copyright : (c) The University of Glasgow 2001,
@@ -75,9 +80,6 @@ import Control.Monad.Trans.RWS.CPS as CPSRWS
7580
import Control.Monad.Trans.Writer.CPS as CPSWriter
7681
#endif
7782

78-
import Control.Monad
79-
import Data.Monoid
80-
8183
class Monad m => MonadCont m where
8284
{- | @callCC@ (call-with-current-continuation)
8385
calls a function with the current continuation as its argument.
@@ -98,9 +100,7 @@ class Monad m => MonadCont m where
98100
even if it is many layers deep within nested computations.
99101
-}
100102
callCC :: ((a -> m b) -> m a) -> m a
101-
#if __GLASGOW_HASKELL__ >= 707
102103
{-# MINIMAL callCC #-}
103-
#endif
104104

105105
instance MonadCont (ContT r m) where
106106
callCC = ContT.callCC

Control/Monad/Error/Class.hs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
{-# LANGUAGE FunctionalDependencies #-}
44
{-# LANGUAGE MultiParamTypeClasses #-}
55
{-# LANGUAGE UndecidableInstances #-}
6+
-- Needed because the CPSed versions of Writer and State are secretly State
7+
-- wrappers, which don't force such constraints, even though they should legally
8+
-- be there.
9+
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
610

711
{- |
812
Module : Control.Monad.Error.Class
@@ -47,8 +51,7 @@ module Control.Monad.Error.Class (
4751
mapError,
4852
) where
4953

50-
import qualified Control.Exception
51-
import Control.Monad.Trans.Except (Except, ExceptT)
54+
import Control.Monad.Trans.Except (ExceptT)
5255
import qualified Control.Monad.Trans.Except as ExceptT (throwE, catchE)
5356
import Control.Monad.Trans.Identity as Identity
5457
import Control.Monad.Trans.Maybe as Maybe
@@ -71,14 +74,9 @@ import Control.Monad.Trans.Writer.CPS as CPSWriter
7174

7275
import Control.Monad.Trans.Class (lift)
7376
import Control.Exception (IOException, catch, ioError)
74-
import Control.Monad
75-
76-
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 707
77-
import Control.Monad.Instances ()
78-
#endif
79-
80-
import Data.Monoid
81-
import Prelude (Either(..), Maybe(..), either, flip, (.), IO)
77+
import Control.Monad (Monad)
78+
import Data.Monoid (Monoid)
79+
import Prelude (Either (Left, Right), Maybe (Nothing), either, flip, (.), IO, pure, (<$>), (>>=))
8280

8381
{- |
8482
The strategy of combining computations that can throw exceptions
@@ -112,9 +110,7 @@ class (Monad m) => MonadError e m | m -> e where
112110
Note that @handler@ and the do-block must have the same return type.
113111
-}
114112
catchError :: m a -> (e -> m a) -> m a
115-
#if __GLASGOW_HASKELL__ >= 707
116113
{-# MINIMAL throwError, catchError #-}
117-
#endif
118114

119115
{- |
120116
Lifts an @'Either' e@ into any @'MonadError' e@.
@@ -126,7 +122,7 @@ where @action1@ returns an 'Either' to represent errors.
126122
@since 2.2.2
127123
-}
128124
liftEither :: MonadError e m => Either e a -> m a
129-
liftEither = either throwError return
125+
liftEither = either throwError pure
130126

131127
instance MonadError IOException IO where
132128
throwError = ioError
@@ -220,14 +216,14 @@ instance
220216

221217
-- | 'MonadError' analogue to the 'Control.Exception.try' function.
222218
tryError :: MonadError e m => m a -> m (Either e a)
223-
tryError action = (liftM Right action) `catchError` (return . Left)
219+
tryError action = (Right <$> action) `catchError` (pure . Left)
224220

225221
-- | 'MonadError' analogue to the 'withExceptT' function.
226222
-- Modify the value (but not the type) of an error. The type is
227223
-- fixed because of the functional dependency @m -> e@. If you need
228224
-- to change the type of @e@ use 'mapError'.
229225
withError :: MonadError e m => (e -> e) -> m a -> m a
230-
withError f action = tryError action >>= either (throwError . f) return
226+
withError f action = tryError action >>= either (throwError . f) pure
231227

232228
-- | As 'handle' is flipped 'Control.Exception.catch', 'handleError'
233229
-- is flipped 'catchError'.

Control/Monad/Except.hs

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -36,49 +36,20 @@ module Control.Monad.Except
3636
-- * Warning
3737
-- $warning
3838
-- * Monads with error handling
39-
MonadError(..),
40-
liftEither,
41-
tryError,
42-
withError,
43-
handleError,
44-
mapError,
45-
46-
-- * The ExceptT monad transformer
47-
ExceptT(ExceptT),
48-
Except,
49-
50-
runExceptT,
51-
mapExceptT,
52-
withExceptT,
53-
runExcept,
54-
mapExcept,
55-
withExcept,
56-
57-
module Control.Monad,
58-
module Control.Monad.Fix,
59-
module Control.Monad.Trans,
39+
Error.MonadError(..),
40+
Error.liftEither,
41+
Error.tryError,
42+
Error.withError,
43+
Error.handleError,
44+
Error.mapError,
6045
-- * Example 1: Custom Error Data Type
6146
-- $customErrorExample
6247

6348
-- * Example 2: Using ExceptT Monad Transformer
6449
-- $ExceptTExample
6550
) where
6651

67-
import Control.Monad.Error.Class
68-
import Control.Monad.Trans
69-
import Control.Monad.Trans.Except
70-
( ExceptT(ExceptT), Except, except
71-
, runExcept, runExceptT
72-
, mapExcept, mapExceptT
73-
, withExcept, withExceptT
74-
)
75-
76-
import Control.Monad
77-
import Control.Monad.Fix
78-
79-
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 707
80-
import Control.Monad.Instances ()
81-
#endif
52+
import qualified Control.Monad.Error.Class as Error
8253

8354
{- $warning
8455
Please do not confuse 'ExceptT' and 'throwError' with 'Control.Exception.Exception' /

Control/Monad/Identity.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,7 @@ version of that monad.
3535
module Control.Monad.Identity (
3636
module Data.Functor.Identity,
3737
module Control.Monad.Trans.Identity,
38-
39-
module Control.Monad,
40-
module Control.Monad.Fix,
4138
) where
4239

4340
import Data.Functor.Identity
4441
import Control.Monad.Trans.Identity
45-
46-
import Control.Monad
47-
import Control.Monad.Fix

Control/Monad/RWS/CPS.hs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ module Control.Monad.RWS.CPS (
4040
withRWST,
4141
-- * Strict Reader-writer-state monads
4242
module Control.Monad.RWS.Class,
43-
module Control.Monad,
44-
module Control.Monad.Fix,
4543
module Control.Monad.Trans,
46-
module Data.Monoid,
4744
) where
4845

4946
import Control.Monad.RWS.Class
@@ -53,10 +50,6 @@ import Control.Monad.Trans.RWS.CPS (
5350
RWS, rws, runRWS, evalRWS, execRWS, mapRWS, withRWS,
5451
RWST, runRWST, evalRWST, execRWST, mapRWST, withRWST)
5552

56-
import Control.Monad
57-
import Control.Monad.Fix
58-
import Data.Monoid
59-
6053
#else
6154
-- | This module ordinarily re-exports @Control.Monad.Trans.RWS.CPS@ from
6255
-- @transformers >= 0.5.6@, which is not currently installed. Therefore, this

Control/Monad/RWS/Class.hs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,15 @@ import Control.Monad.Reader.Class
3535
import Control.Monad.State.Class
3636
import Control.Monad.Writer.Class
3737

38-
import Control.Monad.Trans.Class
39-
import Control.Monad.Trans.Except(ExceptT)
40-
import Control.Monad.Trans.Maybe(MaybeT)
41-
import Control.Monad.Trans.Identity(IdentityT)
38+
import Control.Monad.Trans.Except (ExceptT)
39+
import Control.Monad.Trans.Maybe (MaybeT)
40+
import Control.Monad.Trans.Identity (IdentityT)
4241
#if MIN_VERSION_transformers(0,5,6)
4342
import qualified Control.Monad.Trans.RWS.CPS as CPS (RWST)
4443
#endif
4544
import qualified Control.Monad.Trans.RWS.Lazy as Lazy (RWST)
4645
import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST)
4746

48-
import Data.Monoid
49-
5047
class (Monoid w, MonadReader r m, MonadWriter w m, MonadState s m)
5148
=> MonadRWS r w s m | m -> r, m -> w, m -> s
5249

Control/Monad/RWS/Lazy.hs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ module Control.Monad.RWS.Lazy (
3535
withRWST,
3636
-- * Lazy Reader-writer-state monads
3737
module Control.Monad.RWS.Class,
38-
module Control.Monad,
39-
module Control.Monad.Fix,
4038
module Control.Monad.Trans,
41-
module Data.Monoid,
4239
) where
4340

4441
import Control.Monad.RWS.Class
@@ -47,7 +44,3 @@ import Control.Monad.Trans
4744
import Control.Monad.Trans.RWS.Lazy (
4845
RWS, rws, runRWS, evalRWS, execRWS, mapRWS, withRWS,
4946
RWST(RWST), runRWST, evalRWST, execRWST, mapRWST, withRWST)
50-
51-
import Control.Monad
52-
import Control.Monad.Fix
53-
import Data.Monoid

Control/Monad/RWS/Strict.hs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,12 @@ module Control.Monad.RWS.Strict (
3535
withRWST,
3636
-- * Strict Reader-writer-state monads
3737
module Control.Monad.RWS.Class,
38-
module Control.Monad,
39-
module Control.Monad.Fix,
4038
module Control.Monad.Trans,
41-
module Data.Monoid,
4239
) where
4340

4441
import Control.Monad.RWS.Class
45-
4642
import Control.Monad.Trans
43+
4744
import Control.Monad.Trans.RWS.Strict (
4845
RWS, rws, runRWS, evalRWS, execRWS, mapRWS, withRWS,
4946
RWST(RWST), runRWST, evalRWST, execRWST, mapRWST, withRWST)
50-
51-
import Control.Monad
52-
import Control.Monad.Fix
53-
import Data.Monoid

Control/Monad/Reader.hs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ than using the 'Control.Monad.State.State' monad.
3737

3838
module Control.Monad.Reader (
3939
-- * MonadReader class
40-
MonadReader(..),
41-
asks,
40+
MonadReader.MonadReader(..),
41+
MonadReader.asks,
4242
-- * The Reader monad
4343
Reader,
4444
runReader,
@@ -49,8 +49,6 @@ module Control.Monad.Reader (
4949
runReaderT,
5050
mapReaderT,
5151
withReaderT,
52-
module Control.Monad,
53-
module Control.Monad.Fix,
5452
module Control.Monad.Trans,
5553
-- * Example 1: Simple Reader Usage
5654
-- $simpleReaderExample
@@ -62,15 +60,12 @@ module Control.Monad.Reader (
6260
-- $ReaderTExample
6361
) where
6462

65-
import Control.Monad.Reader.Class
63+
import qualified Control.Monad.Reader.Class as MonadReader
64+
import Control.Monad.Trans
6665

6766
import Control.Monad.Trans.Reader (
6867
Reader, runReader, mapReader, withReader,
6968
ReaderT(ReaderT), runReaderT, mapReaderT, withReaderT)
70-
import Control.Monad.Trans
71-
72-
import Control.Monad
73-
import Control.Monad.Fix
7469

7570
{- $simpleReaderExample
7671

0 commit comments

Comments
 (0)