intro 0.0.2.2 → 0.1.0.0
raw patch · 3 files changed
+69/−38 lines, 3 filesdep +semigroupsdep ~basedep ~bifunctorsdep ~binaryPVP ok
version bump matches the API change (PVP)
Dependencies added: semigroups
Dependency ranges changed: base, bifunctors, binary, dlist, safe, transformers, writer-cps-mtl
API changes (from Hackage documentation)
- Intro: panic :: HasCallStack => a
+ Intro: panic :: HasCallStack => String -> a
Files
- intro.cabal +23/−20
- src/Intro.hs +35/−15
- src/Intro/Trustworthy.hs +11/−3
intro.cabal view
@@ -3,8 +3,8 @@ -- see: https://github.com/sol/hpack name: intro-version: 0.0.2.2-synopsis: Total Prelude with Text and Monad transformers+version: 0.1.0.0+synopsis: \"Fixed Prelude\" - Mostly total and safe, provides Text and Monad transformers description: Modern Prelude which provides safe alternatives for most of the partial functions. Text is preferred over String. Container types and Monad transformers are provided. Most important - this Prelude avoids fanciness. This means it just reexports from base and commonly used libraries and doesn\'t invent its own stuff. Everything is in one file. category: Prelude stability: experimental@@ -15,7 +15,7 @@ copyright: 2016 Daniel Mendler license: MIT license-file: LICENSE-tested-with: GHC == 8.0.1+tested-with: GHC == 7.10.3, GHC == 8.0.1 build-type: Simple cabal-version: >= 1.10 @@ -28,23 +28,26 @@ src ghc-options: -Wall build-depends:- base >= 4.9 && < 5.0- , bifunctors >= 5.4 && < 5.5- , binary >= 0.8 && < 0.9- , bytestring >= 0.9 && < 0.11- , containers >= 0.5 && < 0.6- , deepseq >= 1.4 && < 1.5- , dlist >= 0.8 && < 0.9- , extra >= 1.5.1 && < 1.6- , hashable >= 1.2 && < 1.3- , mtl >= 2.2 && < 2.3- , safe >= 0.3.10 && < 0.4- , string-conversions >= 0.4 && < 0.5- , tagged >= 0.8 && < 0.9- , text >= 0.7 && < 1.3- , transformers >= 0.5 && < 0.6- , unordered-containers >= 0.2 && < 0.3- , writer-cps-mtl >= 0.1.1 && < 0.2+ base >= 4.8 && < 5.0+ , bifunctors >= 5.2 && < 5.5+ , binary >= 0.7 && < 0.9+ , bytestring >= 0.9 && < 0.11+ , containers >= 0.5 && < 0.6+ , deepseq >= 1.4 && < 1.5+ , dlist >= 0.7 && < 0.9+ , extra >= 1.5.1 && < 1.6+ , hashable >= 1.2 && < 1.3+ , mtl >= 2.2 && < 2.3+ , safe >= 0.3 && < 0.4+ , string-conversions >= 0.4 && < 0.5+ , tagged >= 0.8 && < 0.9+ , text >= 0.7 && < 1.3+ , transformers >= 0.4 && < 0.6+ , unordered-containers >= 0.2 && < 0.3+ , writer-cps-mtl >= 0.1 && < 0.2+ if impl(ghc < 8.0)+ build-depends:+ semigroups >= 0.9 && < 1 exposed-modules: Intro other-modules:
src/Intro.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE Safe #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- |@@ -13,9 +14,9 @@ -- Stability : experimental -- Portability : portable ----- Modern Prelude which provides safe alternatives for most of the partial functions. 'Text' is preferred over 'String'.--- Container types and Monad transformers are provided. Most important - this Prelude avoids fanciness.--- This means it just reexports from base and commonly used libraries and doesn\'t invent its own stuff. Everything is in one file.+-- Modern Prelude which provides safe alternatives for most of the partial functions and a focus on nice documentation.+-- Text is preferred over String. Container types and Monad transformers are provided.+-- Most important - this Prelude avoids fanciness. This means it just reexports from base and commonly used libraries and doesn\'t invent its own stuff. Everything is in one file. -- -- Some 'Prelude' functions are missing from 'Intro'. More general variants are available for the following functions: --@@ -141,13 +142,13 @@ , Data.List.zipWith3 -- , Data.List.cycle -- partial , Safe.headDef- , Safe.headMay+ , Safe.headMay -- prefer pattern match , Safe.initDef , Safe.initMay , Safe.lastDef , Safe.lastMay , Safe.tailDef- , Safe.tailMay+ , Safe.tailMay -- prefer pattern match , Safe.cycleMay , Safe.cycleDef @@ -299,28 +300,36 @@ -- ** Show , Text.Show.Show+#if MIN_VERSION_base(4,9,0) , Data.Functor.Classes.Show1 , Data.Functor.Classes.Show2+#endif , show , showS -- ** Read , Text.Read.Read+#if MIN_VERSION_base(4,9,0) , Data.Functor.Classes.Read1 , Data.Functor.Classes.Read2+#endif , readMaybe -- * Equality and Ordering -- ** Eq , Data.Eq.Eq((==), (/=))+#if MIN_VERSION_base(4,9,0) , Data.Functor.Classes.Eq1 , Data.Functor.Classes.Eq2+#endif -- ** Ord , Data.Ord.Ord(compare, (<), (>), (<=), (>=), max, min)+#if MIN_VERSION_base(4,9,0) , Data.Functor.Classes.Ord1 , Data.Functor.Classes.Ord2+#endif , Data.Ord.Ordering(LT,GT,EQ) , Data.Ord.Down(Down) , Data.Ord.comparing@@ -373,7 +382,7 @@ , (Data.Functor.<$>) , map , Data.Functor.void- , Data.Functor.Const.Const(Const, getConst)+ , Control.Applicative.Const(Const, getConst) -- Data.Functor.Const , Data.Functor.Identity.Identity(Identity, runIdentity) -- ** Foldable@@ -431,8 +440,12 @@ , Data.List.NonEmpty.some1 -- ** Monad+#if MIN_VERSION_base(4,9,0) , Control.Monad.Monad((>>=)) , Control.Monad.Fail.MonadFail(fail)+#else+ , Control.Monad.Monad((>>=), fail)+#endif , (Control.Monad.=<<) , (Control.Monad.<=<) , (Control.Monad.>=>)@@ -550,8 +563,10 @@ , Data.Binary.Binary -- * Type level+#if MIN_VERSION_base(4,9,0) , Data.Kind.Type , Data.Kind.Constraint+#endif , Data.Proxy.Proxy(Proxy) , Data.Tagged.Tagged(Tagged) , Data.Tagged.unTagged@@ -604,7 +619,6 @@ import qualified Control.Monad import qualified Control.Monad.Except import qualified Control.Monad.Extra-import qualified Control.Monad.Fail import qualified Control.Monad.RWS.CPS import qualified Control.Monad.Reader import qualified Control.Monad.State.Strict@@ -625,8 +639,6 @@ import qualified Data.Foldable import qualified Data.Function import qualified Data.Functor-import qualified Data.Functor.Classes-import qualified Data.Functor.Const import qualified Data.Functor.Identity import qualified Data.HashMap.Lazy import qualified Data.HashMap.Strict@@ -635,7 +647,6 @@ import qualified Data.Int import qualified Data.IntMap.Strict import qualified Data.IntSet-import qualified Data.Kind import qualified Data.List import qualified Data.List.Extra import qualified Data.List.NonEmpty@@ -659,7 +670,6 @@ import qualified Data.Void import qualified Data.Word import qualified GHC.Generics-import qualified GHC.Stack.Types import qualified Intro.Trustworthy import qualified Numeric.Natural import qualified Prelude@@ -669,6 +679,16 @@ import qualified Text.Read import qualified Text.Show +#if MIN_VERSION_base(4,9,0)+import qualified Control.Monad.Fail+import qualified Data.Functor.Classes+import qualified Data.Kind+import qualified GHC.Stack.Types+#define HAS_CALL_STACK GHC.Stack.Types.HasCallStack =>+#else+#define HAS_CALL_STACK+#endif+ -- | Alias for lazy 'Data.Text.Lazy.Text' type LText = Data.Text.Lazy.Text @@ -805,7 +825,7 @@ {-# INLINE appendFileUtf8 #-} -- | Throw an undefined error. Use only for debugging.-undefined :: GHC.Stack.Types.HasCallStack => a+undefined :: HAS_CALL_STACK a undefined = Prelude.undefined {-# WARNING undefined "'undefined' remains in code" #-} @@ -836,8 +856,8 @@ -- -- In general, prefer total functions. You can use 'Data.Maybe.Maybe', 'Data.Either.Either', -- 'Control.Monad.Except.ExceptT' or 'Control.Monad.Except.MonadError' for error handling.-panic :: GHC.Stack.Types.HasCallStack => a-panic = Prelude.error $- "Panic!\n" <>+panic :: HAS_CALL_STACK String -> a+panic msg = Prelude.error $+ "Panic: " <> msg <> "\n\n" <> "Please submit a bug report including the stacktrace\n" <> "and a description on how to reproduce the bug."
src/Intro/Trustworthy.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- |@@ -41,6 +42,13 @@ import qualified Debug.Trace import qualified GHC.Exts +#if MIN_VERSION_base(4,9,0)+#define APPLICATIVE Applicative+#else+#define APPLICATIVE Monad+import Control.Monad (Monad)+#endif+ -- | The 'trace' function outputs the trace message given as its first argument, -- before returning the second argument as its result. --@@ -71,7 +79,7 @@ -- > traceM $ "x: " ++ show x -- > y <- ... -- > traceM $ "y: " ++ show y-traceM :: Applicative m => Text -> m ()+traceM :: APPLICATIVE m => Text -> m () traceM = Debug.Trace.traceM . Data.Text.unpack {-# WARNING traceM "'traceM' remains in code" #-} @@ -89,7 +97,7 @@ -- | Like 'traceStack' but returning unit in an arbitrary 'Applicative' context. Allows -- for convenient use in do-notation.-traceStackM :: Applicative m => Text -> m ()+traceStackM :: APPLICATIVE m => Text -> m () traceStackM s = traceStack s $ pure () {-# WARNING traceStackM "'traceStackM' remains in code" #-} @@ -115,7 +123,7 @@ -- > traceShowM $ x -- > y <- ... -- > traceShowM $ x + y-traceShowM :: (Show a, Applicative m) => a -> m ()+traceShowM :: (Show a, APPLICATIVE m) => a -> m () traceShowM = Debug.Trace.traceShowM {-# WARNING traceShowM "'traceShowM' remains in code" #-}