From a2340df867e066effa7afba9cc00c1b7f5e7d9bf Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Sun, 10 Dec 2017 14:34:36 -0800 Subject: [PATCH] Explicit exports and add additional transformers. --- postlude.cabal | 1 + src/Postlude.hs | 161 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 122 insertions(+), 40 deletions(-) diff --git a/postlude.cabal b/postlude.cabal index 0809fde..66f4ba7 100644 --- a/postlude.cabal +++ b/postlude.cabal @@ -18,5 +18,6 @@ library hs-source-dirs: src default-language: Haskell2010 build-depends: base >= 4.7 && < 5, + either == 4.4.1.1, mtl == 2.2.1, transformers == 0.5.5.0 diff --git a/src/Postlude.hs b/src/Postlude.hs index e1368de..9065034 100644 --- a/src/Postlude.hs +++ b/src/Postlude.hs @@ -1,56 +1,89 @@ {-# LANGUAGE NoImplicitPrelude #-} +-- The following maps all imports into a single module alias for easy exporting. +-- In all cases, we choose to explicitly list all exports (and avoid the use of +-- the .. syntactic construct) to make it clear what is being included when +-- importing the Postlude module. +-- +-- It is generally expected one will add the -XNoImplicitPrelude pragma to the +-- file Postlude is being used in, and to import Postlude without any +-- qualification. module Postlude (module X) where import Control.Applicative as X - ( Applicative (..) + ( Applicative, (*>), (<*), (<*>), pure , (<$>) - , pure ) import Control.Arrow as X - ( Arrow (..) - , ArrowChoice (..) - , ArrowLoop (..) - , ArrowMonad (..) - , ArrowPlus (..) - , ArrowZero (..) + ( Arrow, (&&&), (***), arr, first, second + , ArrowChoice, (+++), (|||), left, right + , ArrowLoop, loop + , ArrowMonad + , ArrowPlus, (<+>) + , ArrowZero, zeroArrow , (<<<) , (>>>) , returnA ) import Control.Monad as X - ( Monad (..) - , MonadPlus (..) - , filterM + ( Monad, (>>=), (>>), return, fail + , MonadPlus, mplus, mzero , guard ) import Control.Monad.Reader as X - ( MonadReader (..) + ( MonadReader, ask, local, reader + , Reader + , runReader + ) + +import Control.Monad.State as X + ( State + ) + +import Control.Monad.Writer as X + ( Writer ) import Control.Monad.Trans as X - ( MonadIO (..) + ( MonadIO, liftIO , lift ) +import Control.Monad.Trans.Either as X + ( EitherT, runEitherT + ) + import Control.Monad.Trans.Except as X - ( ExceptT (..) - , runExceptT + -- Note runExceptT is not actually a type declaration within the ExceptT + -- newtype but writing as follows for consistency's sake. + ( ExceptT, runExceptT ) import Control.Monad.Trans.Maybe as X - ( MaybeT (..) + ( MaybeT, runMaybeT ) import Control.Monad.Trans.Reader as X - ( ReaderT (..) + ( ReaderT, runReaderT + ) + +-- Note there also exists a strict interpretation but we default to the lazy +-- implementation. +import Control.Monad.Trans.State as X + ( StateT, runStateT + ) + +-- Note there also exists a strict interpretation but we default to the lazy +-- implementation. +import Control.Monad.Trans.Writer as X + ( WriterT, runWriterT ) import Data.Bool as X - ( Bool (..) + ( Bool, Bool(False), Bool(True) , (&&) , (||) , not @@ -58,15 +91,15 @@ import Data.Bool as X ) import Data.Char as X - ( Char (..) + ( Char ) import Data.Either as X - ( Either (..) + ( Either, Either(Left), Either(Right) ) import Data.Eq as X - ( Eq (..) + ( Eq, (/=), (==) ) import Data.Function as X @@ -81,14 +114,14 @@ import Data.Function as X ) import Data.Functor as X - ( Functor (..) + ( Functor, (<$), fmap , ($>) , (<$>) , void ) import Data.Functor.Identity as X - ( Identity (..) + ( Identity, runIdentity ) import Data.Int as X @@ -114,16 +147,16 @@ import Data.List as X ) import Data.Maybe as X - ( Maybe (..) + ( Maybe, Maybe(Just), Maybe(Nothing) ) import Data.Monoid as X - ( Monoid (..) + ( Monoid, mappend, mconcat, mempty ) import Data.Ord as X - ( Ord (..) - , Ordering (..) + ( Ord, (<), (<=), (>), (>=), compare, max, min + , Ordering, Ordering(EQ), Ordering(GT), Ordering(LT) ) import Data.String as X @@ -131,12 +164,20 @@ import Data.String as X ) import Data.Traversable as X - ( Traversable (..) + ( Traversable, mapM, sequence, sequenceA, traverse ) import GHC.Enum as X - ( Bounded (..) - , Enum (..) + ( Bounded, maxBound, minBound + , Enum + , enumFrom + , enumFromThen + , enumFromThenTo + , enumFromTo + , fromEnum + , pred + , succ + , toEnum ) import GHC.Err as X @@ -144,26 +185,62 @@ import GHC.Err as X ) import GHC.Float as X - ( Double (..) - , Float (..) - , Floating (..) - , RealFloat (..) + ( Double + , Float + , Floating + , (**) + , acos + , acosh + , asin + , asinh + , atan + , atanh + , cos + , cosh + , exp + , expm1 + , log + , log1mexp + , log1p + , log1pexp + , logBase + , pi + , sin + , sinh + , sqrt + , tan + , tanh + , RealFloat + , atan2 + , decodeFloat + , encodeFloat + , exponent + , floatDigits + , floatRadix + , floatRange + , isDenormalized + , isIEEE + , isInfinite + , isNaN + , isNegativeZero + , scaleFloat + , significand ) import GHC.Num as X - ( Num (..) + ( Num, (*), (+), (-), abs, fromInteger, negate, signum , Integer ) import GHC.Real as X - ( Fractional (..) - , Integral (..) - , Ratio (..) + ( Fractional, (/), fromRational, recip + , Integral, div, divMod, mod, quot, quotRem, rem, toInteger + , Ratio , Rational ) import GHC.Show as X - ( Show (..) + ( Show, show, showList, showsPrec ) import System.Environment as X @@ -174,7 +251,11 @@ import System.IO as X ( FilePath , Handle , IO - , IOMode (..) + , IOMode + , IOMode(AppendMode) + , IOMode(ReadMode) + , IOMode(ReadWriteMode) + , IOMode(WriteMode) , openFile , print , stderr