packages feed

basic-prelude 0.2.0.0 → 0.3.0.0

raw patch · 3 files changed

+129/−95 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- CorePrelude: (++) :: Monoid w => w -> w -> w
- CorePrelude: concat :: Monoid w => [w] -> w
- CorePrelude: elem :: Eq a => a -> [a] -> Bool
- CorePrelude: empty :: Monoid w => w
- CorePrelude: or :: [Bool] -> Bool
- CorePrelude: unzip :: [(a, b)] -> ([a], [b])
- CorePrelude: zip :: [a] -> [b] -> [(a, b)]
- CorePrelude: zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
+ BasicPrelude: (++) :: Monoid w => w -> w -> w
+ BasicPrelude: concat :: Monoid w => [w] -> w
+ BasicPrelude: empty :: Monoid w => w
+ BasicPrelude: gcd :: Integral a => a -> a -> a
+ BasicPrelude: getChar :: IO Char
+ BasicPrelude: interact :: (Text -> Text) -> IO ()
+ BasicPrelude: intercalate :: Text -> [Text] -> Text
+ BasicPrelude: ioError :: IOError -> IO a
+ BasicPrelude: lcm :: Integral a => a -> a -> a
+ BasicPrelude: lex :: ReadS String
+ BasicPrelude: lines :: Text -> [Text]
+ BasicPrelude: putChar :: Char -> IO ()
+ BasicPrelude: readList :: Read a => ReadS [a]
+ BasicPrelude: readLn :: Read a => IO a
+ BasicPrelude: readParen :: Bool -> ReadS a -> ReadS a
+ BasicPrelude: reads :: Read a => ReadS a
+ BasicPrelude: readsPrec :: Read a => Int -> ReadS a
+ BasicPrelude: showChar :: Char -> ShowS
+ BasicPrelude: showList :: Show a => [a] -> ShowS
+ BasicPrelude: showParen :: Bool -> ShowS -> ShowS
+ BasicPrelude: showString :: String -> ShowS
+ BasicPrelude: shows :: Show a => a -> ShowS
+ BasicPrelude: showsPrec :: Show a => Int -> a -> ShowS
+ BasicPrelude: type IOError = IOException
+ BasicPrelude: type ReadS a = String -> [(a, String)]
+ BasicPrelude: type ShowS = String -> String
+ BasicPrelude: type String = [Char]
+ BasicPrelude: unlines :: [Text] -> Text
+ BasicPrelude: unwords :: [Text] -> Text
+ BasicPrelude: userError :: String -> IOError
+ BasicPrelude: words :: Text -> [Text]
+ CorePrelude: (<>) :: Monoid m => m -> m -> m
+ CorePrelude: class Bounded a
+ CorePrelude: class Read a
+ CorePrelude: maxBound :: Bounded a => a
+ CorePrelude: minBound :: Bounded a => a
- BasicPrelude: getContents :: IO LText
+ BasicPrelude: getContents :: IO Text

Files

BasicPrelude.hs view
@@ -1,135 +1,165 @@ {-# 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 CorePrelude+  ( -- * Module exports+    module CorePrelude   , module Data.List-  , module Prelude-  , module Data.Text-  , module Data.Text.Lazy.IO   , module Control.Monad++    -- * Enhanced exports+    -- ** Simpler name for a typeclassed operation   , map-  , show-  , read+  , empty+  , (++)+  , concat+    -- ** Strict implementation   , sum   , product-  , putStr-  , getLine-  , getContents+    -- ** Text for Read and Show operations+  , show+  , read+  , readIO+    -- ** FilePath for file operations   , readFile   , writeFile   , appendFile-  , readIO-  ) where -import qualified Data.Text as T-import qualified Data.Text.IO as T-import qualified Data.Text.Lazy.IO as TL-import qualified Prelude as P-import qualified Filesystem.Path.CurrentOS as F+    -- * Text exports+    -- ** Text operations (Pure)+  , Text.lines+  , Text.words+  , Text.unlines+  , Text.unwords+  , Text.intercalate+    -- ** Text operations (IO)+  , Text.putStr+  , Text.getLine+  , LText.getContents+  , LText.interact +    -- * Miscellaneous prelude re-exports+    -- ** Math+  , Prelude.gcd+  , Prelude.lcm+    -- ** Show and Read+  , Prelude.String+  , 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+    -- ** IO operations+  , Prelude.putChar+  , Prelude.getChar+  , Prelude.readLn+    -- ** Exceptions+  , Prelude.IOError+  , Prelude.ioError+  , Prelude.userError+  ) where+ import CorePrelude  import Data.List hiding-  ( -- already in CorePrelude+  ( -- prefer monoid versions instead     (++)   , concat-       -- prefer Text versions instead   , lines   , words   , unlines   , unwords   , intercalate-       -- prefer map = fmap instead   , map-         -- prefer strict versions   , sum   , product   ) -import Prelude-  ( Bounded (..)-  , gcd-  , lcm-  , seq-  , ($!)-  , curry-  , until-  , asTypeOf-  , undefined-  , String-  , ReadS-  , ShowS-  , Read (..)-  , Show (showsPrec, showList)-  , reads-  , shows-  , showChar-  , showString-  , showParen-  , readParen-  , lex-  , IOError-  , ioError-  , userError-  , putChar-  , getChar-  , readLn-  )--import Data.Text-  ( lines-  , words-  , unlines-  , unwords-  , intercalate-  )--import Data.Text.Lazy.IO-  ( interact-  )- -- 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.IO as LText +import qualified Filesystem.Path.CurrentOS as FilePath+import qualified Prelude++++-- | > map = fmap map :: (Functor f) => (a -> b) -> f a -> f b map = fmap -show :: Show a => a -> Text-show = T.pack . P.show+-- | > empty = mempty+empty :: Monoid w => w+empty = mempty -read :: Read a => Text -> a-read = P.read . T.unpack+infixr 5 ++ +-- | > (++) = mappend+(++) :: Monoid w => w -> w -> w+(++) = mappend++-- | > concat = mconcat+concat :: Monoid w => [w] -> w+concat = mconcat+++-- | 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 -putStr :: Text -> IO ()-putStr = T.putStr -getLine :: IO Text-getLine = T.getLine+-- | Convert a value to readable Text+show :: Show a => a -> Text+show = Text.pack . Prelude.show -getContents :: IO LText-getContents = TL.getContents+-- | 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 = T.readFile . F.encodeString+readFile = Text.readFile . FilePath.encodeString +-- | Write Text to a file.+-- The file is truncated to zero length before writing begins. writeFile :: FilePath -> Text -> IO ()-writeFile = T.writeFile . F.encodeString+writeFile = Text.writeFile . FilePath.encodeString +-- | Write Text to the end of a file. appendFile :: FilePath -> Text -> IO ()-appendFile = T.appendFile . F.encodeString--readIO :: Read a => Text -> IO a-readIO = P.readIO . T.unpack+appendFile = Text.appendFile . FilePath.encodeString 
CorePrelude.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE CPP #-}+ module CorePrelude     ( -- * Standard       -- ** Operators@@ -18,12 +20,7 @@     , Prelude.flip     , Prelude.const     , Prelude.error-    , Prelude.zip-    , Prelude.unzip-    , Prelude.zipWith-    , Prelude.or     , Data.Text.IO.putStrLn-    , Prelude.elem     , Prelude.odd     , Prelude.even     , Prelude.uncurry@@ -36,8 +33,10 @@       -- ** Type classes     , Prelude.Ord (..)     , Prelude.Eq (..)+    , Prelude.Bounded (..)     , Prelude.Enum (..)     , Prelude.Show+    , Prelude.Read     , Prelude.Functor (..)     , Prelude.Monad (..)     , (Control.Monad.=<<)@@ -91,9 +90,7 @@     , Prelude.realToFrac       -- ** Monoids     , Monoid (..)-    , empty-    , concat-    , (++)+    , (<>)       -- ** Arrow     , Control.Arrow.first     , Control.Arrow.second@@ -173,19 +170,24 @@ import Data.HashMap.Strict (HashMap) import Data.HashSet (HashSet) +#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 -empty :: Monoid w => w-empty = mempty -concat :: Monoid w => [w] -> w-concat = mconcat+#if !MIN_VERSION_base(4,5,0) -infixr 5  ++-(++) :: Monoid w => w -> w -> w-(++) = mappend+infixr 6 <>+(<>) :: Monoid w => w -> w -> w+(<>) = mappend+{-# INLINE (<>) #-} +#endif+ equating :: Eq a => (b -> a) -> b -> b -> Bool equating = Data.Function.on (Prelude.==)+
basic-prelude.cabal view
@@ -1,5 +1,5 @@ name:                basic-prelude-version:             0.2.0.0+version:             0.3.0.0 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.@@ -10,6 +10,8 @@     .     Release history:     .+    [0.3] Moved a number of exports from @BasicPrelude@ to @CorePrelude@ and vice-versa.+    .     [0.2] Renamed @BasicPrelude@ to @CorePrelude@ and added a new @BasicPrelude@ module provided a full-featured @Prelude@ alternative. Also added a number of new exports.     .     [0.1] Initial version, code taken from @classy-prelude@ with a few minor tweaks.@@ -17,7 +19,7 @@ homepage:            https://github.com/snoyberg/basic-prelude license:             MIT license-file:        LICENSE-author:              Michael Snoyman+author:              Michael Snoyman, Dan Burton maintainer:          michael@snoyman.com  category:            Control