Skip to content

Commit

Permalink
Remove some re-exports, raise minimum GHC to 8.6, remove unneeded CPP
Browse files Browse the repository at this point in the history
  • Loading branch information
kozross committed May 1, 2022
1 parent ecb525a commit bfddbe8
Show file tree
Hide file tree
Showing 21 changed files with 198 additions and 296 deletions.
34 changes: 34 additions & 0 deletions .nvimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
" Enable hlint and GHC via Cabal
let g:ale_linters = {'haskell': ['cabal-build']}
" ... only
let g:ale_linters_explicit = 1
" Don't lint until I save
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_enter = 0

call ale#Set('haskell_cabal_build_options', '')

function! GetCabalCommand(buffer) abort
let l:flags = ale#Var(a:buffer, 'haskell_cabal_build_options')
return 'cabal new-build ' . l:flags
endfunction

call ale#linter#Define('haskell', {
\ 'name': 'cabal_build',
\ 'aliases': ['cabal-build'],
\ 'output_stream': 'stderr',
\ 'executable': 'cabal',
\ 'command': function('GetCabalCommand'),
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
\})

let g:neoformat_enabled_cabal = []

let g:neoformat_enabled_haskell = []

" Enable automagic autoformatting
augroup fmt
autocmd!
autocmd BufWritePre * undojoin | Neoformat
augroup end
34 changes: 14 additions & 20 deletions Control/Monad/Cont.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,20 @@ to understand and maintain.

module Control.Monad.Cont (
-- * MonadCont class
MonadCont(..),
MonadCont.MonadCont(..),
-- * The Cont monad
Cont,
cont,
runCont,
evalCont,
mapCont,
withCont,
Cont.Cont,
Cont.cont,
Cont.runCont,
Cont.evalCont,
Cont.mapCont,
Cont.withCont,
-- * The ContT monad transformer
ContT(ContT),
runContT,
evalContT,
mapContT,
withContT,
module Control.Monad,
module Control.Monad.Trans,
Cont.ContT(ContT),
Cont.runContT,
Cont.evalContT,
Cont.mapContT,
Cont.withContT,
-- * Example 1: Simple Continuation Usage
-- $simpleContExample

Expand All @@ -76,12 +74,8 @@ module Control.Monad.Cont (
-- $ContTExample
) where

import Control.Monad.Cont.Class

import Control.Monad.Trans
import Control.Monad.Trans.Cont

import Control.Monad
import qualified Control.Monad.Cont.Class as MonadCont
import qualified Control.Monad.Trans.Cont as Cont

{- $simpleContExample
Calculating length of a list continuation-style:
Expand Down
10 changes: 5 additions & 5 deletions Control/Monad/Cont/Class.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{-# LANGUAGE CPP #-}
-- Needed because the CPSed versions of Writer and State are secretly State
-- wrappers, which don't force such constraints, even though they should legally
-- be there.
{-# OPTIONS_GHC -Wno-redundant-constraints #-}

{- |
Module : Control.Monad.Cont.Class
Copyright : (c) The University of Glasgow 2001,
Expand Down Expand Up @@ -75,9 +80,6 @@ import Control.Monad.Trans.RWS.CPS as CPSRWS
import Control.Monad.Trans.Writer.CPS as CPSWriter
#endif

import Control.Monad
import Data.Monoid

class Monad m => MonadCont m where
{- | @callCC@ (call-with-current-continuation)
calls a function with the current continuation as its argument.
Expand All @@ -98,9 +100,7 @@ class Monad m => MonadCont m where
even if it is many layers deep within nested computations.
-}
callCC :: ((a -> m b) -> m a) -> m a
#if __GLASGOW_HASKELL__ >= 707
{-# MINIMAL callCC #-}
#endif

instance MonadCont (ContT r m) where
callCC = ContT.callCC
Expand Down
26 changes: 11 additions & 15 deletions Control/Monad/Error/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
-- Needed because the CPSed versions of Writer and State are secretly State
-- wrappers, which don't force such constraints, even though they should legally
-- be there.
{-# OPTIONS_GHC -Wno-redundant-constraints #-}

{- |
Module : Control.Monad.Error.Class
Expand Down Expand Up @@ -47,8 +51,7 @@ module Control.Monad.Error.Class (
mapError,
) where

import qualified Control.Exception
import Control.Monad.Trans.Except (Except, ExceptT)
import Control.Monad.Trans.Except (ExceptT)
import qualified Control.Monad.Trans.Except as ExceptT (throwE, catchE)
import Control.Monad.Trans.Identity as Identity
import Control.Monad.Trans.Maybe as Maybe
Expand All @@ -71,14 +74,9 @@ import Control.Monad.Trans.Writer.CPS as CPSWriter

import Control.Monad.Trans.Class (lift)
import Control.Exception (IOException, catch, ioError)
import Control.Monad

#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 707
import Control.Monad.Instances ()
#endif

import Data.Monoid
import Prelude (Either(..), Maybe(..), either, flip, (.), IO)
import Control.Monad (Monad)
import Data.Monoid (Monoid)
import Prelude (Either (Left, Right), Maybe (Nothing), either, flip, (.), IO, pure, (<$>), (>>=))

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

{- |
Lifts an @'Either' e@ into any @'MonadError' e@.
Expand All @@ -126,7 +122,7 @@ where @action1@ returns an 'Either' to represent errors.
@since 2.2.2
-}
liftEither :: MonadError e m => Either e a -> m a
liftEither = either throwError return
liftEither = either throwError pure

instance MonadError IOException IO where
throwError = ioError
Expand Down Expand Up @@ -220,14 +216,14 @@ instance

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

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

-- | As 'handle' is flipped 'Control.Exception.catch', 'handleError'
-- is flipped 'catchError'.
Expand Down
43 changes: 7 additions & 36 deletions Control/Monad/Except.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,49 +36,20 @@ module Control.Monad.Except
-- * Warning
-- $warning
-- * Monads with error handling
MonadError(..),
liftEither,
tryError,
withError,
handleError,
mapError,

-- * The ExceptT monad transformer
ExceptT(ExceptT),
Except,

runExceptT,
mapExceptT,
withExceptT,
runExcept,
mapExcept,
withExcept,

module Control.Monad,
module Control.Monad.Fix,
module Control.Monad.Trans,
Error.MonadError(..),
Error.liftEither,
Error.tryError,
Error.withError,
Error.handleError,
Error.mapError,
-- * Example 1: Custom Error Data Type
-- $customErrorExample

-- * Example 2: Using ExceptT Monad Transformer
-- $ExceptTExample
) where

import Control.Monad.Error.Class
import Control.Monad.Trans
import Control.Monad.Trans.Except
( ExceptT(ExceptT), Except, except
, runExcept, runExceptT
, mapExcept, mapExceptT
, withExcept, withExceptT
)

import Control.Monad
import Control.Monad.Fix

#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 707
import Control.Monad.Instances ()
#endif
import qualified Control.Monad.Error.Class as Error

{- $warning
Please do not confuse 'ExceptT' and 'throwError' with 'Control.Exception.Exception' /
Expand Down
6 changes: 0 additions & 6 deletions Control/Monad/Identity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ version of that monad.
module Control.Monad.Identity (
module Data.Functor.Identity,
module Control.Monad.Trans.Identity,

module Control.Monad,
module Control.Monad.Fix,
) where

import Data.Functor.Identity
import Control.Monad.Trans.Identity

import Control.Monad
import Control.Monad.Fix
7 changes: 0 additions & 7 deletions Control/Monad/RWS/CPS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ module Control.Monad.RWS.CPS (
withRWST,
-- * Strict Reader-writer-state monads
module Control.Monad.RWS.Class,
module Control.Monad,
module Control.Monad.Fix,
module Control.Monad.Trans,
module Data.Monoid,
) where

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

import Control.Monad
import Control.Monad.Fix
import Data.Monoid

#else
-- | This module ordinarily re-exports @Control.Monad.Trans.RWS.CPS@ from
-- @transformers >= 0.5.6@, which is not currently installed. Therefore, this
Expand Down
9 changes: 3 additions & 6 deletions Control/Monad/RWS/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,15 @@ import Control.Monad.Reader.Class
import Control.Monad.State.Class
import Control.Monad.Writer.Class

import Control.Monad.Trans.Class
import Control.Monad.Trans.Except(ExceptT)
import Control.Monad.Trans.Maybe(MaybeT)
import Control.Monad.Trans.Identity(IdentityT)
import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans.Maybe (MaybeT)
import Control.Monad.Trans.Identity (IdentityT)
#if MIN_VERSION_transformers(0,5,6)
import qualified Control.Monad.Trans.RWS.CPS as CPS (RWST)
#endif
import qualified Control.Monad.Trans.RWS.Lazy as Lazy (RWST)
import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST)

import Data.Monoid

class (Monoid w, MonadReader r m, MonadWriter w m, MonadState s m)
=> MonadRWS r w s m | m -> r, m -> w, m -> s

Expand Down
7 changes: 0 additions & 7 deletions Control/Monad/RWS/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ module Control.Monad.RWS.Lazy (
withRWST,
-- * Lazy Reader-writer-state monads
module Control.Monad.RWS.Class,
module Control.Monad,
module Control.Monad.Fix,
module Control.Monad.Trans,
module Data.Monoid,
) where

import Control.Monad.RWS.Class
Expand All @@ -47,7 +44,3 @@ import Control.Monad.Trans
import Control.Monad.Trans.RWS.Lazy (
RWS, rws, runRWS, evalRWS, execRWS, mapRWS, withRWS,
RWST(RWST), runRWST, evalRWST, execRWST, mapRWST, withRWST)

import Control.Monad
import Control.Monad.Fix
import Data.Monoid
9 changes: 1 addition & 8 deletions Control/Monad/RWS/Strict.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,12 @@ module Control.Monad.RWS.Strict (
withRWST,
-- * Strict Reader-writer-state monads
module Control.Monad.RWS.Class,
module Control.Monad,
module Control.Monad.Fix,
module Control.Monad.Trans,
module Data.Monoid,
) where

import Control.Monad.RWS.Class

import Control.Monad.Trans

import Control.Monad.Trans.RWS.Strict (
RWS, rws, runRWS, evalRWS, execRWS, mapRWS, withRWS,
RWST(RWST), runRWST, evalRWST, execRWST, mapRWST, withRWST)

import Control.Monad
import Control.Monad.Fix
import Data.Monoid
13 changes: 4 additions & 9 deletions Control/Monad/Reader.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ than using the 'Control.Monad.State.State' monad.

module Control.Monad.Reader (
-- * MonadReader class
MonadReader(..),
asks,
MonadReader.MonadReader(..),
MonadReader.asks,
-- * The Reader monad
Reader,
runReader,
Expand All @@ -49,8 +49,6 @@ module Control.Monad.Reader (
runReaderT,
mapReaderT,
withReaderT,
module Control.Monad,
module Control.Monad.Fix,
module Control.Monad.Trans,
-- * Example 1: Simple Reader Usage
-- $simpleReaderExample
Expand All @@ -62,15 +60,12 @@ module Control.Monad.Reader (
-- $ReaderTExample
) where

import Control.Monad.Reader.Class
import qualified Control.Monad.Reader.Class as MonadReader
import Control.Monad.Trans

import Control.Monad.Trans.Reader (
Reader, runReader, mapReader, withReader,
ReaderT(ReaderT), runReaderT, mapReaderT, withReaderT)
import Control.Monad.Trans

import Control.Monad
import Control.Monad.Fix

{- $simpleReaderExample
Expand Down
Loading

0 comments on commit bfddbe8

Please sign in to comment.