intro 0.0.2.1 → 0.0.2.2
raw patch · 3 files changed
+126/−60 lines, 3 filesdep ~bifunctorsdep ~binarydep ~containersPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: bifunctors, binary, containers, deepseq, dlist, hashable, mtl, tagged, transformers, unordered-containers
API changes (from Hackage documentation)
- Intro: bifoldl :: Bifoldable p => (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c
- Intro: listToMaybe :: [a] -> Maybe a
- Intro: maybeToList :: Maybe a -> [a]
+ Intro: bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> a
+ Intro: bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c
+ Intro: foldl1Def :: Foldable t => a -> (a -> a -> a) -> t a -> a
+ Intro: foldl1May :: Foldable t => (a -> a -> a) -> t a -> Maybe a
+ Intro: foldr1Def :: Foldable t => a -> (a -> a -> a) -> t a -> a
+ Intro: foldr1May :: Foldable t => (a -> a -> a) -> t a -> Maybe a
+ Intro: subtract :: Num a => a -> a -> a
Files
- intro.cabal +12/−11
- src/Intro.hs +99/−49
- src/Intro/Trustworthy.hs +15/−0
intro.cabal view
@@ -3,10 +3,11 @@ -- see: https://github.com/sol/hpack name: intro-version: 0.0.2.1+version: 0.0.2.2 synopsis: Total Prelude with 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 homepage: https://github.com/minad/intro#readme bug-reports: https://github.com/minad/intro/issues author: Daniel Mendler <mail@daniel-mendler.de>@@ -28,21 +29,21 @@ ghc-options: -Wall build-depends: base >= 4.9 && < 5.0- , bifunctors >= 5.4.1 && < 5.5- , binary >= 0.8.3.0 && < 0.9+ , bifunctors >= 5.4 && < 5.5+ , binary >= 0.8 && < 0.9 , bytestring >= 0.9 && < 0.11- , containers >= 0.5.7.1 && < 0.6- , deepseq >= 1.4.2.0 && < 1.5- , dlist >= 0.8.0.2 && < 0.9+ , containers >= 0.5 && < 0.6+ , deepseq >= 1.4 && < 1.5+ , dlist >= 0.8 && < 0.9 , extra >= 1.5.1 && < 1.6- , hashable >= 1.2.4.0 && < 1.3- , mtl >= 2.2.1 && < 2.3+ , 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.5 && < 0.9+ , tagged >= 0.8 && < 0.9 , text >= 0.7 && < 1.3- , transformers >= 0.5.2.0 && < 0.6- , unordered-containers >= 0.2.7.1 && < 0.3+ , transformers >= 0.5 && < 0.6+ , unordered-containers >= 0.2 && < 0.3 , writer-cps-mtl >= 0.1.1 && < 0.2 exposed-modules: Intro
src/Intro.hs view
@@ -1,3 +1,4 @@+{-# OPTIONS_HADDOCK show-extensions #-} {-# LANGUAGE Safe #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NoImplicitPrelude #-}@@ -12,10 +13,41 @@ -- Stability : experimental -- Portability : portable ----- Modern Prelude which provides safe alternatives for most of the partial functions. Text is preferred over String.+-- 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. --+-- Some 'Prelude' functions are missing from 'Intro'. More general variants are available for the following functions:+--+-- * '>>' = 'Control.Applicative.*>'+-- * '++' = 'Data.Semigroup.<>'+-- * 'concat' = 'Data.Monoid.mconcat'+-- * 'fmap' is replaced by generalized 'map'+-- * 'mapM' = 'Control.Applicative.traverse'+-- * 'mapM_' = 'Data.Foldable.traverse_'+-- * 'return' = 'Control.Applicative.pure'+-- * 'sequence' = 'Control.Applicative.sequenceA'+-- * 'sequence_' = 'Control.Applicative.sequenceA_'+--+-- Unsafe functions are not provided. Use the '*May' or '*Def' alternatives instead.+--+-- * 'cycle', 'head', 'tail', 'init', 'last'+-- * 'foldl1', 'foldr1', 'maximum', 'minimum'+-- * 'toEnum'+-- * 'read' is replaced by 'readMaybe'+--+-- These functions are not provided for various reasons:+--+-- * 'succ' and 'pred' are not commonly used and don't have safe alternatives. Maybe ask if these could be added to the 'safe' package?+-- * '!!' is unsafe and /O(n)/. Use a 'Data.Map.Strict.Map' instead.+-- * 'lines', 'unlines', 'words' and 'unwords' are not provided. Use qualified 'Data.Text' import instead.+-- * Instead of 'foldl', it is recommended to use 'Data.Foldable.foldl''.+-- * 'lex' is not commonly used. Use a parser combinator library instead.+-- * 'gcd' and 'lcm' are not commonly used.+-- * 'error' and 'errorWithoutStackTrace' are not provided. Use 'panic' instead.+-- * 'ioError' and 'userError' are not provided. Import separately if needed.+-- * Some 'Text.Read' and 'Text.Show' class functions are not provided. Don't write these instances yourself.+-- ----------------------------------------------------------------------------- module Intro (@@ -53,10 +85,10 @@ , Data.Maybe.fromMaybe , Data.Maybe.isJust , Data.Maybe.isNothing- , Data.Maybe.listToMaybe+ --, Data.Maybe.listToMaybe -- use headMay+ -- , Data.Maybe.maybeToList -- use toList , Data.Maybe.mapMaybe , Data.Maybe.maybe- , Data.Maybe.maybeToList -- ** List , Intro.Trustworthy.IsList(@@ -190,9 +222,11 @@ -- * Numeric types - -- ** Integer types+ -- ** Big integers , Prelude.Integer , Numeric.Natural.Natural++ -- ** Small integers , Data.Int.Int , Data.Int.Int8 , Data.Int.Int16@@ -220,6 +254,7 @@ -- ** Num , Prelude.Num((+), (-), (*), negate, abs, signum, fromInteger)+ , Prelude.subtract , (Prelude.^) -- partial functions! -- ** Real@@ -231,6 +266,8 @@ , Prelude.fromIntegral , Prelude.even , Prelude.odd+ --, Prelude.gcd+ --, Prelude.lcm -- ** Fractional , Prelude.Fractional((/), recip, fromRational) -- partial functions@@ -339,6 +376,46 @@ , Data.Functor.Const.Const(Const, getConst) , Data.Functor.Identity.Identity(Identity, runIdentity) + -- ** Foldable+ , Data.Foldable.Foldable(elem, fold, foldMap,+ foldr, foldr',+ -- foldl, -- hide the bad one+ foldl',+ product, sum, toList)+ , Data.Foldable.null+ , Data.Foldable.length+ , Data.Foldable.foldrM+ , Data.Foldable.foldlM+ , Data.Foldable.traverse_+ , Data.Foldable.for_+ , Data.Foldable.asum+ , Data.Foldable.concatMap+ , Data.Foldable.all+ , Data.Foldable.any+ , Data.Foldable.or+ , Data.Foldable.and+ , Data.Foldable.find+ , Data.Foldable.notElem+ , Data.Foldable.sequenceA_+ , Safe.Foldable.foldl1May+ , Safe.Foldable.foldl1Def+ , Safe.Foldable.foldr1May+ , Safe.Foldable.foldr1Def+ , Safe.Foldable.maximumByMay+ , Safe.Foldable.maximumByDef+ , Safe.Foldable.minimumByMay+ , Safe.Foldable.minimumByDef+ , Safe.Foldable.maximumMay+ , Safe.Foldable.maximumDef+ , Safe.Foldable.minimumMay+ , Safe.Foldable.minimumDef++ -- ** Traversable+ , Data.Traversable.Traversable(traverse, sequenceA)+ , Data.Traversable.for+ , Data.Traversable.mapAccumL+ , Data.Traversable.mapAccumR+ -- ** Applicative , Control.Applicative.Applicative(pure, (<*>), (*>), (<*)) , Control.Applicative.ZipList(ZipList, getZipList)@@ -378,47 +455,15 @@ , (Control.Monad.Extra.&&^) , (Control.Monad.Extra.||^) - -- ** Foldable- , Data.Foldable.Foldable(elem, fold, foldMap,- foldr, foldr',- -- foldl, -- hide the bad one- foldl',- product, sum, toList)- , Data.Foldable.null- , Data.Foldable.length- , Data.Foldable.foldrM- , Data.Foldable.foldlM- , Data.Foldable.traverse_- , Data.Foldable.for_- , Data.Foldable.asum- , Data.Foldable.concatMap- , Data.Foldable.all- , Data.Foldable.any- , Data.Foldable.or- , Data.Foldable.and- , Data.Foldable.find- , Data.Foldable.notElem- , Data.Foldable.sequenceA_- , Safe.Foldable.maximumByMay- , Safe.Foldable.maximumByDef- , Safe.Foldable.minimumByMay- , Safe.Foldable.minimumByDef- , Safe.Foldable.maximumMay- , Safe.Foldable.maximumDef- , Safe.Foldable.minimumMay- , Safe.Foldable.minimumDef-- -- ** Traversable- , Data.Traversable.Traversable(traverse, sequenceA)- , Data.Traversable.for- , Data.Traversable.mapAccumL- , Data.Traversable.mapAccumR- -- ** Bifunctor , Data.Bifunctor.Bifunctor(bimap, first, second) -- ** Bifoldable- , Data.Bifoldable.Bifoldable(bifoldr, bifoldl, bifoldMap)+ , Data.Bifoldable.Bifoldable(bifoldr+ --, bifoldl -- not strict enough+ , bifoldMap)+ , Data.Bifoldable.bifoldl'+ , Data.Bifoldable.bifoldr' , Data.Bifoldable.bitraverse_ , Data.Bifoldable.bisequenceA_ , Data.Bifoldable.bifor_@@ -511,17 +556,22 @@ , Data.Tagged.Tagged(Tagged) , Data.Tagged.unTagged - -- * File and Console IO- , Prelude.FilePath+ -- * IO , System.IO.IO , Control.Monad.Trans.MonadIO(liftIO)- , print++ -- ** Console+ , getChar , getContents , getLine- , getChar+ , print , putChar , putStr , putStrLn+ --, interact++ -- ** File+ , Prelude.FilePath , readFile , writeFile , appendFile@@ -541,7 +591,7 @@ , Intro.Trustworthy.traceStackM ) where -import Control.Category ((.))+import Data.Function ((.), ($)) import Control.Monad.Trans (MonadIO(liftIO)) import Data.ByteString (ByteString) import Data.Semigroup ((<>))@@ -759,7 +809,7 @@ undefined = Prelude.undefined {-# WARNING undefined "'undefined' remains in code" #-} --- | '(<>)' lifted to 'Control.Applicative.Applicative'+-- | '<>' lifted to 'Control.Applicative.Applicative' (<>^) :: (Control.Applicative.Applicative f, Data.Semigroup.Semigroup a) => f a -> f a -> f a (<>^) = Control.Applicative.liftA2 (Data.Semigroup.<>) infixr 6 <>^@@ -773,7 +823,7 @@ infixr 8 .: {-# INLINE (.:) #-} --- | '()' lifted to an 'Control.Applicative.Applicative'.+-- | @()@ lifted to an 'Control.Applicative.Applicative'. -- -- @skip = 'Control.Applicative.pure' ()@ skip :: Control.Applicative.Applicative m => m ()@@ -787,7 +837,7 @@ -- 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 Data.Function.$+panic = Prelude.error $ "Panic!\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,20 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-}++-----------------------------------------------------------------------------+-- |+-- Module : Intro.Trustworthy+-- Copyright : (c) Daniel Mendler 2016+-- License : MIT+--+-- Maintainer : mail@daniel-mendler.de+-- Stability : experimental+-- Portability : portable+--+-- Trustworthy reexports from 'GHC.Exts' and 'Debug.Trace'+--+-----------------------------------------------------------------------------+ module Intro.Trustworthy ( Data.DList.DList , GHC.Exts.IsList(