basic-prelude 0.4.1 → 0.7.0
raw patch · 6 files changed
Files
- BasicPrelude.hs +0/−213
- ChangeLog.md +39/−0
- CorePrelude.hs +0/−267
- basic-prelude.cabal +43/−35
- src/BasicPrelude.hs +317/−0
- src/CorePrelude.hs +270/−0
− BasicPrelude.hs
@@ -1,213 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}---- | BasicPrelude mostly re-exports--- several key libraries in their entirety.--- The exception is Data.List,--- where various functions are replaced--- by similar versions that are either--- generalized, operate on Text,--- or are implemented strictly.-module BasicPrelude- ( -- * Module exports- module CorePrelude- , module Data.List- , module Control.Monad-- -- * Enhanced exports- -- ** Simpler name for a typeclassed operation- , map- , empty- , (++)- , concat- , intercalate- -- ** Strict implementation- , sum- , product- -- ** Text for Read and Show operations- , show- , fromShow- , read- , readIO- -- ** FilePath for file operations- , readFile- , writeFile- , appendFile-- -- * Text exports- -- ** Text operations (Pure)- , Text.lines- , Text.words- , Text.unlines- , Text.unwords- , textToString- , ltextToString- , fpToText- , fpFromText- , fpToString- , encodeUtf8- , decodeUtf8- -- ** Text operations (IO)- , Text.getLine- , LText.getContents- , LText.interact-- -- * Miscellaneous prelude re-exports- -- ** Math- , Prelude.gcd- , Prelude.lcm- -- ** Show and Read- , Prelude.ShowS- , Prelude.showsPrec- , Prelude.showList- , Prelude.shows- , Prelude.showChar- , Prelude.showString- , Prelude.showParen- , Prelude.ReadS- , Prelude.readsPrec- , Prelude.readList- , Prelude.reads- , Prelude.readParen- , Prelude.lex- , readMay- -- ** IO operations- , Prelude.putChar- , Prelude.getChar- , Prelude.readLn- ) where--import CorePrelude--import Data.List hiding- ( -- prefer monoid versions instead- (++)- , concat- , intercalate- -- prefer Text versions instead- , lines- , words- , unlines- , unwords- -- prefer map = fmap instead- , map- -- prefer strict versions- , sum- , product- )---- Import *all of the things* from Control.Monad,--- specifically, the list-based things that--- CorePrelude doesn't export-import Control.Monad---import qualified Data.Text as Text-import qualified Data.Text.IO as Text-import qualified Data.Text.Lazy as LText-import qualified Data.Text.Lazy.IO as LText-import qualified Prelude-import Data.Text.Encoding (encodeUtf8, decodeUtf8With)-import Data.Text.Encoding.Error (lenientDecode)-import qualified Safe---- | > map = fmap-map :: (Functor f) => (a -> b) -> f a -> f b-map = fmap---- | > empty = mempty-empty :: Monoid w => w-empty = mempty--infixr 5 ++---- | > (++) = mappend-(++) :: Monoid w => w -> w -> w-(++) = mappend---- | > concat = mconcat-concat :: Monoid w => [w] -> w-concat = mconcat---- | > intercalate = mconcat .: intersperse-intercalate :: Monoid w => w -> [w] -> w-intercalate xs xss = mconcat (Data.List.intersperse xs xss)----- | Compute the sum of a finite list of numbers.-sum :: Num a => [a] -> a-sum = foldl' (+) 0---- | Compute the product of a finite list of numbers.-product :: Num a => [a] -> a-product = foldl' (*) 1----- | Convert a value to readable Text-show :: Show a => a -> Text-show = Text.pack . Prelude.show---- | Convert a value to readable IsString------ Since 0.3.12-fromShow :: (Show a, IsString b) => a -> b-fromShow = fromString . Prelude.show---- | Parse Text to a value-read :: Read a => Text -> a-read = Prelude.read . Text.unpack---- | The readIO function is similar to read--- except that it signals parse failure to the IO monad--- instead of terminating the program. -readIO :: Read a => Text -> IO a-readIO = Prelude.readIO . Text.unpack----- | Read a file and return the contents of the file as Text.--- The entire file is read strictly.-readFile :: FilePath -> IO Text-readFile = Text.readFile---- | Write Text to a file.--- The file is truncated to zero length before writing begins.-writeFile :: FilePath -> Text -> IO ()-writeFile = Text.writeFile---- | Write Text to the end of a file.-appendFile :: FilePath -> Text -> IO ()-appendFile = Text.appendFile--textToString :: Text -> Prelude.String-textToString = Text.unpack--ltextToString :: LText -> Prelude.String-ltextToString = LText.unpack---- | This function assumes file paths are encoded in UTF8. If it--- cannot decode the 'FilePath', the result is just an approximation.------ Since 0.3.13-fpToText :: FilePath -> Text-fpToText = Text.pack-{-# DEPRECATED fpToText "Use Data.Text.pack" #-}---- |--- Since 0.3.13-fpFromText :: Text -> FilePath-fpFromText = Text.unpack-{-# DEPRECATED fpFromText "Use Data.Text.unpack" #-}---- |--- Since 0.3.13-fpToString :: FilePath -> Prelude.String-fpToString = id-{-# DEPRECATED fpToString "Use id" #-}---- | Note that this is /not/ the standard @Data.Text.Encoding.decodeUtf8@. That--- function will throw impure exceptions on any decoding errors. This function--- instead uses @decodeLenient@.-decodeUtf8 :: ByteString -> Text-decodeUtf8 = decodeUtf8With lenientDecode--readMay :: Read a => Text -> Maybe a-readMay = Safe.readMay . Text.unpack
ChangeLog.md view
@@ -1,3 +1,42 @@+## 0.7.0++* Export applicative version of Foldable and Traversable functions [#72](https://github.com/snoyberg/basic-prelude/issues/72)+* Generalize all IO functions to MonadIO [#75](https://github.com/snoyberg/basic-prelude/issues/75)+* Use `foldl1` for `maximumBy` and `minimumBy` [#74](https://github.com/snoyberg/basic-prelude/issues/74)+* Remove nonexistent `foldr'` from `Data.List` hiding list+* Remove the `lifted-base` dependency. This means that `CorePrelude`+ and `BasicPrelude` no longer expose any exception handling+ functions. This is intentional: the new recommendations from this+ library are to use an async-exception-aware exception handling+ library, either+ [safe-exceptions](https://haskell-lang.org/library/safe-exceptions)+ or [unliftio](https://www.stackage.org/package/unliftio).++## 0.6.1.1++* Add `HasCallStack` for `terror`++## 0.6.1++* Generalize `sum` and `product` to `Foldable` [#69](https://github.com/snoyberg/basic-prelude/issues/69)++## 0.6.0++* Export `show` from `Show` typeclass, and rename current `show` to `tshow` [#67](https://github.com/snoyberg/basic-prelude/issues/67)++## 0.5.2++* Expose `bool`++## 0.5.1++* Expose `asum`+* Deprecate `empty` (so it can be replaced with `Alternative`'s `empty`)++## 0.5.0++* Expose more Foldable/Traversable stuff+ ## 0.4.1 * terror
− CorePrelude.hs
@@ -1,267 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE CPP #-}--module CorePrelude- ( -- * Standard- -- ** Operators- (Prelude.$)- , (Prelude.$!)- , (Prelude.&&)- , (Prelude.||)- , (Control.Category..)- -- ** Functions- , Prelude.not- , Prelude.otherwise- , Prelude.fst- , Prelude.snd- , Control.Category.id- , Prelude.maybe- , Prelude.either- , Prelude.flip- , Prelude.const- , Prelude.error- , putStr- , putStrLn- , print- , getArgs- , terror- , Prelude.odd- , Prelude.even- , Prelude.uncurry- , Prelude.curry- , Data.Tuple.swap- , Prelude.until- , Prelude.asTypeOf- , Prelude.undefined- , Prelude.seq- -- ** Type classes- , Prelude.Ord (..)- , Prelude.Eq (..)- , Prelude.Bounded (..)- , Prelude.Enum (..)- , Prelude.Show- , Prelude.Read- , Prelude.Functor (..)- , Prelude.Monad (..)- , (Control.Monad.=<<)- , Data.String.IsString (..)- -- ** Numeric type classes- , Prelude.Num (..)- , Prelude.Real (..)- , Prelude.Integral (..)- , Prelude.Fractional (..)- , Prelude.Floating (..)- , Prelude.RealFrac (..)- , Prelude.RealFloat(..)- -- ** Data types- , Prelude.Maybe (..)- , Prelude.Ordering (..)- , Prelude.Bool (..)- , Prelude.Char- , Prelude.IO- , Prelude.Either (..)- -- * Re-exports- -- ** Packed reps- , ByteString- , LByteString- , Text- , LText- -- ** Containers- , Map- , HashMap- , IntMap- , Set- , HashSet- , IntSet- , Seq- , Vector- , UVector- , Unbox- , SVector- , Data.Vector.Storable.Storable- , Hashable- -- ** Numbers- , Word- , Word8- , Word32- , Word64- , Prelude.Int- , Int32- , Int64- , Prelude.Integer- , Prelude.Rational- , Prelude.Float- , Prelude.Double- -- ** Numeric functions- , (Prelude.^)- , (Prelude.^^)- , Prelude.subtract- , Prelude.fromIntegral- , Prelude.realToFrac- -- ** Monoids- , Monoid (..)- , (<>)- -- ** Arrow- , Control.Arrow.first- , Control.Arrow.second- , (Control.Arrow.***)- , (Control.Arrow.&&&)- -- ** Maybe- , Data.Maybe.mapMaybe- , Data.Maybe.catMaybes- , Data.Maybe.fromMaybe- , Data.Maybe.isJust- , Data.Maybe.isNothing- , Data.Maybe.listToMaybe- , Data.Maybe.maybeToList- -- ** Either- , Data.Either.partitionEithers- , Data.Either.lefts- , Data.Either.rights- -- ** Ord- , Data.Function.on- , Data.Ord.comparing- , equating- , GHC.Exts.Down (..)- -- ** Applicative- , Control.Applicative.Applicative (..)- , (Control.Applicative.<$>)- , (Control.Applicative.<|>)- -- ** Monad- , (Control.Monad.>=>)- -- ** Transformers- , Control.Monad.Trans.Class.lift- , Control.Monad.IO.Class.MonadIO- , Control.Monad.IO.Class.liftIO- -- ** Exceptions- , Control.Exception.Exception (..)- , Data.Typeable.Typeable (..)- , Control.Exception.SomeException- , Control.Exception.IOException- , Control.Exception.Lifted.throwIO- , Control.Exception.Lifted.try- , Control.Exception.Lifted.tryJust- , Control.Exception.Lifted.catch- , Control.Exception.Lifted.catchJust- , Control.Exception.Lifted.handle- , Control.Exception.Lifted.handleJust- , Control.Exception.Lifted.bracket- , Control.Exception.Lifted.bracket_- , Control.Exception.Lifted.bracketOnError- , Control.Exception.Lifted.onException- , Control.Exception.Lifted.finally- , Control.Exception.Lifted.mask- , Control.Exception.Lifted.mask_- , Control.Exception.Lifted.uninterruptibleMask- , Control.Exception.Lifted.uninterruptibleMask_- , module System.IO.Error- -- ** Files- , Prelude.FilePath- , (F.</>)- , (F.<.>)- -- ** Strings- , Prelude.String- -- ** Hashing- , hash- , hashWithSalt- -- ** Command line args- , readArgs- ) where--import qualified Prelude-import Prelude (Char, (.), Eq, Bool)--import Data.Hashable (Hashable, hash, hashWithSalt)-import Data.Vector.Unboxed (Unbox)--import Data.Monoid (Monoid (..))-import qualified Control.Arrow-import Control.Applicative-import qualified Control.Category-import qualified Control.Monad-import qualified Control.Exception-import qualified Control.Exception.Lifted-import qualified Data.Typeable--import Data.Word (Word8, Word32, Word64, Word)-import Data.Int (Int32, Int64)--import qualified Data.Text.IO--import qualified Data.Maybe-import qualified Data.Either-import qualified Data.Ord-import qualified Data.Function-import qualified Data.Tuple-import qualified Data.String--import qualified Control.Monad.Trans.Class-import qualified Control.Monad.IO.Class-import Control.Monad.IO.Class (MonadIO (liftIO))--import Data.ByteString (ByteString)-import qualified Data.ByteString.Lazy-import Data.Text (Text)-import qualified Data.Text.Lazy-import Data.Vector (Vector)-import qualified Data.Vector.Unboxed-import qualified Data.Vector.Storable-import Data.Map (Map)-import Data.Set (Set)-import Data.IntMap (IntMap)-import Data.IntSet (IntSet)-import Data.Sequence (Seq)-import Data.HashMap.Strict (HashMap)-import Data.HashSet (HashSet)-import qualified ReadArgs-import qualified System.FilePath as F--import qualified System.Environment-import qualified Data.Text-import qualified Data.List-import System.IO.Error hiding (catch, try)-import qualified GHC.Exts--#if MIN_VERSION_base(4,5,0)-import Data.Monoid ((<>))-#endif--type LText = Data.Text.Lazy.Text-type LByteString = Data.ByteString.Lazy.ByteString-type UVector = Data.Vector.Unboxed.Vector-type SVector = Data.Vector.Storable.Vector---#if !MIN_VERSION_base(4,5,0)--infixr 6 <>-(<>) :: Monoid w => w -> w -> w-(<>) = mappend-{-# INLINE (<>) #-}--#endif--equating :: Eq a => (b -> a) -> b -> b -> Bool-equating = Data.Function.on (Prelude.==)---getArgs :: MonadIO m => m [Text]-getArgs = liftIO (Data.List.map Data.Text.pack <$> System.Environment.getArgs)--putStr :: MonadIO m => Text -> m ()-putStr = liftIO . Data.Text.IO.putStr--putStrLn :: MonadIO m => Text -> m ()-putStrLn = liftIO . Data.Text.IO.putStrLn--print :: (MonadIO m, Prelude.Show a) => a -> m ()-print = liftIO . Prelude.print--readArgs :: (MonadIO m, ReadArgs.ArgumentTuple a) => m a-readArgs = liftIO ReadArgs.readArgs---- | @error@ applied to @Text@------ Since 0.4.1-terror :: Text -> a-terror = Prelude.error . Data.Text.unpack
basic-prelude.cabal view
@@ -1,39 +1,47 @@-name: basic-prelude-version: 0.4.1-synopsis: An enhanced core prelude; a common foundation for alternate preludes.-description:- The premise of @basic-prelude@ is that there are a lot of very commonly desired features missing from the standard @Prelude@, such as commonly used operators (@\<$\>@ and @>=>@, for instance) and imports for common datatypes (e.g., @ByteString@ and @Vector@). At the same time, there are lots of other components which are more debatable, such as providing polymorphic versions of common functions.- .- So @basic-prelude@ is intended to give a common foundation for a number of alternate preludes. The package provides two modules: @CorePrelude@ provides the common ground for other preludes to build on top of, while @BasicPrelude@ exports @CorePrelude@ together with commonly used list functions to provide a drop-in replacement for the standard @Prelude@.- .- Users wishing to have an improved @Prelude@ can use @BasicPrelude@. Developers wishing to create a new prelude should use @CorePrelude@.--homepage: https://github.com/snoyberg/basic-prelude-license: MIT-license-file: LICENSE-author: Michael Snoyman, Dan Burton-maintainer: michael@snoyman.com-extra-source-files: README.md ChangeLog.md+-- This file has been generated from package.yaml by hpack version 0.20.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 9e2114ea9be10fb6a3831b21030119adfd0bc5db6f95b840818e819bb39d4cb5 -category: Control, Prelude-build-type: Simple-cabal-version: >=1.8+name: basic-prelude+version: 0.7.0+synopsis: An enhanced core prelude; a common foundation for alternate preludes.+description: Please see the README on Github at <https://github.com/snoyberg/basic-prelude#readme>+category: Control, Prelude+homepage: https://github.com/snoyberg/basic-prelude#readme+bug-reports: https://github.com/snoyberg/basic-prelude/issues+author: Michael Snoyman, Dan Burton+maintainer: michael@snoyman.com+license: MIT+license-file: LICENSE+build-type: Simple+cabal-version: >= 1.10 -library- exposed-modules: BasicPrelude, CorePrelude- build-depends: base >= 4 && < 5- , hashable- , bytestring- , text- , transformers- , containers- , unordered-containers- , vector- , ReadArgs >= 1.2 && < 1.3- , lifted-base- , safe- , filepath+extra-source-files:+ ChangeLog.md+ README.md source-repository head- type: git- location: git://github.com/snoyberg/basic-prelude.git+ type: git+ location: https://github.com/snoyberg/basic-prelude++library+ hs-source-dirs:+ src+ build-depends:+ base >=4.6 && <5+ , bytestring+ , containers+ , filepath+ , hashable+ , text+ , transformers+ , unordered-containers+ , vector+ exposed-modules:+ BasicPrelude+ CorePrelude+ other-modules:+ Paths_basic_prelude+ default-language: Haskell2010
+ src/BasicPrelude.hs view
@@ -0,0 +1,317 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE CPP #-}++-- | BasicPrelude mostly re-exports+-- several key libraries in their entirety.+-- The exception is Data.List,+-- where various functions are replaced+-- by similar versions that are either+-- generalized, operate on Text,+-- or are implemented strictly.+module BasicPrelude+ ( -- * Module exports+ module CorePrelude+ , module Data.List+ , module Control.Monad++ -- ** Folds and traversals+ , Foldable+ (+ foldMap+ , foldr+ , foldr'+ , foldl+ , foldl'+ , foldr1+ , foldl1+ )+ -- In base-4.8, these are instance methods.+ , elem+ , maximum+ , minimum+ , traverse_+ , sequenceA_+ , for_+ , maximumBy+ , minimumBy+ , Traversable+ (+ traverse+ , sequenceA+ , mapM+ , sequence+ )+ , for++ -- * Enhanced exports+ -- ** Simpler name for a typeclassed operation+ , map+ , empty+ , (++)+ , concat+ , intercalate+ -- ** Strict implementation+ , BasicPrelude.sum+ , BasicPrelude.product+ -- ** Text for Read and Show operations+ , tshow+ , fromShow+ , read+ , readIO+ -- ** FilePath for file operations+ , readFile+ , writeFile+ , appendFile++ -- * Text exports+ -- ** Text operations (Pure)+ , Text.lines+ , Text.words+ , Text.unlines+ , Text.unwords+ , textToString+ , ltextToString+ , fpToText+ , fpFromText+ , fpToString+ , encodeUtf8+ , decodeUtf8+ -- ** Text operations (IO)+ , getLine+ , getContents+ , interact++ -- * Miscellaneous prelude re-exports+ -- ** Math+ , Prelude.gcd+ , Prelude.lcm+ -- ** Show and Read+ , Prelude.Show (..)+ , Prelude.ShowS+ , Prelude.shows+ , Prelude.showChar+ , Prelude.showString+ , Prelude.showParen+ , Prelude.ReadS+ , Prelude.readsPrec+ , Prelude.readList+ , Prelude.reads+ , Prelude.readParen+ , Prelude.lex+ , readMay+ -- ** IO operations+ , getChar+ , putChar+ , readLn+ ) where++import CorePrelude++import Data.List hiding+ ( -- prefer monoid versions instead+ (++)+ , concat+ , intercalate+ -- prefer Text versions instead+ , lines+ , words+ , unlines+ , unwords+ -- prefer map = fmap instead+ , map+ -- prefer strict versions+ , sum+ , product+ -- prefer Foldable versions+ , elem+ , foldl+ , foldl'+ , foldl1+ , foldr+ , foldr1+ , maximum+ , minimum+ , maximumBy+ , minimumBy+ )++-- Import *all of the things* from Control.Monad,+-- specifically, the list-based things that+-- CorePrelude doesn't export+import Control.Monad hiding+ ( -- Also exported by Data.Traversable.+ mapM+ , sequence+ )+++import Data.Foldable (Foldable(..), elem, maximum, minimum, traverse_, sequenceA_, for_)+import Data.Traversable (Traversable(..), for)+import qualified Data.Text as Text+import qualified Data.Text.IO as Text+import qualified Data.Text.Lazy as LText+import qualified Data.Text.Lazy.IO as LText+import qualified Prelude+import Data.Text.Encoding (encodeUtf8, decodeUtf8With)+import Data.Text.Encoding.Error (lenientDecode)+import qualified Text.Read++#if MIN_VERSION_base(4,10,0)+import Data.Foldable (maximumBy, minimumBy)+#else+maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a+maximumBy cmp = foldl1 max'+ where max' x y = case cmp x y of+ GT -> x+ _ -> y++minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a+minimumBy cmp = foldl1 min'+ where min' x y = case cmp x y of+ GT -> y+ _ -> x+#endif++-- | > map = fmap+map :: (Functor f) => (a -> b) -> f a -> f b+map = fmap++-- | > empty = mempty+empty :: Monoid w => w+empty = mempty+{-# DEPRECATED empty "Use mempty" #-}++infixr 5 ++++-- | > (++) = mappend+(++) :: Monoid w => w -> w -> w+(++) = mappend++-- | > concat = mconcat+concat :: Monoid w => [w] -> w+concat = mconcat++-- | > intercalate = mconcat .: intersperse+intercalate :: Monoid w => w -> [w] -> w+intercalate xs xss = mconcat (Data.List.intersperse xs xss)+++-- | Compute the sum of a finite list of numbers.+sum :: (Foldable f, Num a) => f a -> a+sum = Data.Foldable.foldl' (+) 0++-- | Compute the product of a finite list of numbers.+product :: (Foldable f, Num a) => f a -> a+product = Data.Foldable.foldl' (*) 1+++-- | Convert a value to readable Text+--+-- @since 0.6.0+tshow :: Show a => a -> Text+tshow = Text.pack . Prelude.show++-- | Convert a value to readable IsString+--+-- Since 0.3.12+fromShow :: (Show a, IsString b) => a -> b+fromShow = fromString . Prelude.show++-- | Parse Text to a value+read :: Read a => Text -> a+read = Prelude.read . Text.unpack++-- | The readIO function is similar to read+-- except that it signals parse failure to the IO monad+-- instead of terminating the program.+--+-- @since 0.7.0+readIO :: (MonadIO m, Read a) => Text -> m a+readIO = liftIO . Prelude.readIO . Text.unpack+++-- | Read a file and return the contents of the file as Text.+-- The entire file is read strictly.+--+-- @since 0.7.0+readFile :: MonadIO m => FilePath -> m Text+readFile = liftIO . Text.readFile++-- | Write Text to a file.+-- The file is truncated to zero length before writing begins.+--+-- @since 0.7.0+writeFile :: MonadIO m => FilePath -> Text -> m ()+writeFile p = liftIO . Text.writeFile p++-- | Write Text to the end of a file.+--+-- @since 0.7.0+appendFile :: MonadIO m => FilePath -> Text -> m ()+appendFile p = liftIO . Text.appendFile p++textToString :: Text -> Prelude.String+textToString = Text.unpack++ltextToString :: LText -> Prelude.String+ltextToString = LText.unpack++-- | This function assumes file paths are encoded in UTF8. If it+-- cannot decode the 'FilePath', the result is just an approximation.+--+-- Since 0.3.13+fpToText :: FilePath -> Text+fpToText = Text.pack+{-# DEPRECATED fpToText "Use Data.Text.pack" #-}++-- |+-- Since 0.3.13+fpFromText :: Text -> FilePath+fpFromText = Text.unpack+{-# DEPRECATED fpFromText "Use Data.Text.unpack" #-}++-- |+-- Since 0.3.13+fpToString :: FilePath -> Prelude.String+fpToString = id+{-# DEPRECATED fpToString "Use id" #-}++-- | Note that this is /not/ the standard @Data.Text.Encoding.decodeUtf8@. That+-- function will throw impure exceptions on any decoding errors. This function+-- instead uses @decodeLenient@.+decodeUtf8 :: ByteString -> Text+decodeUtf8 = decodeUtf8With lenientDecode++-- |+-- @since 0.7.0+getLine :: MonadIO m => m Text+getLine = liftIO Text.getLine++-- |+-- @since 0.7.0+getContents :: MonadIO m => m LText+getContents = liftIO LText.getContents++-- |+-- @since 0.7.0+interact :: MonadIO m => (LText -> LText) -> m ()+interact = liftIO . LText.interact++readMay :: Read a => Text -> Maybe a+readMay = Text.Read.readMaybe . Text.unpack++-- |+-- @since 0.7.0+getChar :: MonadIO m => m Char+getChar = liftIO Prelude.getChar++-- |+-- @since 0.7.0+putChar :: MonadIO m => Char -> m ()+putChar = liftIO . Prelude.putChar++-- | The 'readLn' function combines 'getLine' and 'readIO'.+--+-- @since 0.7.0+readLn :: (MonadIO m, Read a) => m a+readLn = liftIO Prelude.readLn
+ src/CorePrelude.hs view
@@ -0,0 +1,270 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE CPP #-}++module CorePrelude+ ( -- * Standard+ -- ** Operators+ (Prelude.$)+ , (Prelude.$!)+ , (Prelude.&&)+ , (Prelude.||)+ , (Control.Category..)+ -- ** Functions+ , Prelude.not+ , Prelude.otherwise+ , Prelude.fst+ , Prelude.snd+ , Control.Category.id+ , Prelude.maybe+ , Prelude.either+ , Prelude.flip+ , Prelude.const+ , Prelude.error+ , putStr+ , putStrLn+ , print+ , getArgs+ , terror+ , Prelude.odd+ , Prelude.even+ , Prelude.uncurry+ , Prelude.curry+ , Data.Tuple.swap+ , Prelude.until+ , Prelude.asTypeOf+ , Prelude.undefined+ , Prelude.seq+ -- ** Type classes+ , Prelude.Ord (..)+ , Prelude.Eq (..)+ , Prelude.Bounded (..)+ , Prelude.Enum (..)+ , Prelude.Show+ , Prelude.Read+ , Prelude.Functor (..)+ , Prelude.Monad (..)+ , (Control.Monad.=<<)+ , Data.String.IsString (..)+ -- ** Numeric type classes+ , Prelude.Num (..)+ , Prelude.Real (..)+ , Prelude.Integral (..)+ , Prelude.Fractional (..)+ , Prelude.Floating (..)+ , Prelude.RealFrac (..)+ , Prelude.RealFloat(..)+ -- ** Data types+ , Prelude.Maybe (..)+ , Prelude.Ordering (..)+ , Prelude.Bool (..)+ , Prelude.Char+ , Prelude.IO+ , Prelude.Either (..)+ -- * Re-exports+ -- ** Packed reps+ , ByteString+ , LByteString+ , Text+ , LText+ -- ** Containers+ , Map+ , HashMap+ , IntMap+ , Set+ , HashSet+ , IntSet+ , Seq+ , Vector+ , UVector+ , Unbox+ , SVector+ , Data.Vector.Storable.Storable+ , Hashable+ -- ** Numbers+ , Word+ , Word8+ , Word32+ , Word64+ , Prelude.Int+ , Int32+ , Int64+ , Prelude.Integer+ , Prelude.Rational+ , Prelude.Float+ , Prelude.Double+ -- ** Numeric functions+ , (Prelude.^)+ , (Prelude.^^)+ , Prelude.subtract+ , Prelude.fromIntegral+ , Prelude.realToFrac+ -- ** Monoids+ , Monoid (..)+ , (<>)+ -- ** Folds and traversals+ , Data.Foldable.Foldable+ , Data.Foldable.asum+ , Data.Traversable.Traversable+ -- ** arrow+ , Control.Arrow.first+ , Control.Arrow.second+ , (Control.Arrow.***)+ , (Control.Arrow.&&&)+ -- ** Bool+ , bool+ -- ** Maybe+ , Data.Maybe.mapMaybe+ , Data.Maybe.catMaybes+ , Data.Maybe.fromMaybe+ , Data.Maybe.isJust+ , Data.Maybe.isNothing+ , Data.Maybe.listToMaybe+ , Data.Maybe.maybeToList+ -- ** Either+ , Data.Either.partitionEithers+ , Data.Either.lefts+ , Data.Either.rights+ -- ** Ord+ , Data.Function.on+ , Data.Ord.comparing+ , equating+ , GHC.Exts.Down (..)+ -- ** Applicative+ , Control.Applicative.Applicative (..)+ , (Control.Applicative.<$>)+ , (Control.Applicative.<|>)+ -- ** Monad+ , (Control.Monad.>=>)+ -- ** Transformers+ , Control.Monad.Trans.Class.lift+ , Control.Monad.IO.Class.MonadIO+ , Control.Monad.IO.Class.liftIO+ -- ** Exceptions+ , Control.Exception.Exception (..)+ , Data.Typeable.Typeable (..)+ , Control.Exception.SomeException+ , Control.Exception.IOException+ , module System.IO.Error+ -- ** Files+ , Prelude.FilePath+ , (F.</>)+ , (F.<.>)+ -- ** Strings+ , Prelude.String+ -- ** Hashing+ , hash+ , hashWithSalt+ ) where++import qualified Prelude+import Prelude (Char, (.), Eq, Bool)++import Data.Hashable (Hashable, hash, hashWithSalt)+import Data.Vector.Unboxed (Unbox)++import Data.Monoid (Monoid (..))+import qualified Control.Arrow+import Control.Applicative+import qualified Control.Category+import qualified Control.Monad+import qualified Control.Exception+import qualified Data.Typeable++import qualified Data.Foldable+import qualified Data.Traversable++import Data.Word (Word8, Word32, Word64, Word)+import Data.Int (Int32, Int64)++import qualified Data.Text.IO++import qualified Data.Maybe+import qualified Data.Either+import qualified Data.Ord+import qualified Data.Function+import qualified Data.Tuple+import qualified Data.String++import qualified Control.Monad.Trans.Class+import qualified Control.Monad.IO.Class+import Control.Monad.IO.Class (MonadIO (liftIO))++import Data.ByteString (ByteString)+import qualified Data.ByteString.Lazy+import Data.Text (Text)+import qualified Data.Text.Lazy+import Data.Vector (Vector)+import qualified Data.Vector.Unboxed+import qualified Data.Vector.Storable+import Data.Map (Map)+import Data.Set (Set)+import Data.IntMap (IntMap)+import Data.IntSet (IntSet)+import Data.Sequence (Seq)+import Data.HashMap.Strict (HashMap)+import Data.HashSet (HashSet)+import qualified System.FilePath as F++import qualified System.Environment+import qualified Data.Text+import qualified Data.List+import System.IO.Error hiding (catch, try)+import qualified GHC.Exts++#if MIN_VERSION_base(4,7,0)+import Data.Bool (bool)+#endif++#if MIN_VERSION_base(4,5,0)+import Data.Monoid ((<>))+#endif++#if MIN_VERSION_base(4,9,0)+import GHC.Stack (HasCallStack)+#endif++type LText = Data.Text.Lazy.Text+type LByteString = Data.ByteString.Lazy.ByteString+type UVector = Data.Vector.Unboxed.Vector+type SVector = Data.Vector.Storable.Vector+++#if !MIN_VERSION_base(4,7,0)+bool :: a -> a -> Bool -> a+bool f t b = if b then t else f+#endif++#if !MIN_VERSION_base(4,5,0)++infixr 6 <>+(<>) :: Monoid w => w -> w -> w+(<>) = mappend+{-# INLINE (<>) #-}++#endif++equating :: Eq a => (b -> a) -> b -> b -> Bool+equating = Data.Function.on (Prelude.==)+++getArgs :: MonadIO m => m [Text]+getArgs = liftIO (Data.List.map Data.Text.pack <$> System.Environment.getArgs)++putStr :: MonadIO m => Text -> m ()+putStr = liftIO . Data.Text.IO.putStr++putStrLn :: MonadIO m => Text -> m ()+putStrLn = liftIO . Data.Text.IO.putStrLn++print :: (MonadIO m, Prelude.Show a) => a -> m ()+print = liftIO . Prelude.print++-- | @error@ applied to @Text@+--+-- Since 0.4.1+#if MIN_VERSION_base(4,9,0)+terror :: HasCallStack => Text -> a+#else+terror :: Text -> a+#endif+terror = Prelude.error . Data.Text.unpack