basic-prelude-0.3.4.0/0000755000000000000000000000000012114614021012551 5ustar0000000000000000basic-prelude-0.3.4.0/Setup.hs0000644000000000000000000000005612114614021014206 0ustar0000000000000000import Distribution.Simple main = defaultMain basic-prelude-0.3.4.0/LICENSE0000644000000000000000000000207512114614021013562 0ustar0000000000000000Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. basic-prelude-0.3.4.0/BasicPrelude.hs0000644000000000000000000000753312114614021015457 0ustar0000000000000000{-# 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 , read , readIO -- ** FilePath for file operations , readFile , writeFile , appendFile -- * Text exports -- ** Text operations (Pure) , Text.lines , Text.words , Text.unlines , Text.unwords , textToString , ltextToString -- ** 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 ( -- 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 Filesystem.Path.CurrentOS as FilePath import qualified Prelude -- | > 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 -- | 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 . FilePath.encodeString -- | Write Text to a file. -- The file is truncated to zero length before writing begins. writeFile :: FilePath -> Text -> IO () writeFile = Text.writeFile . FilePath.encodeString -- | Write Text to the end of a file. appendFile :: FilePath -> Text -> IO () appendFile = Text.appendFile . FilePath.encodeString textToString :: Text -> Prelude.String textToString = Text.unpack ltextToString :: LText -> Prelude.String ltextToString = LText.unpack basic-prelude-0.3.4.0/basic-prelude.cabal0000644000000000000000000000454612114614021016265 0ustar0000000000000000name: basic-prelude version: 0.3.4.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. . 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@. . 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. homepage: https://github.com/snoyberg/basic-prelude license: MIT license-file: LICENSE author: Michael Snoyman, Dan Burton maintainer: michael@snoyman.com category: Control, Prelude build-type: Simple cabal-version: >=1.8 library exposed-modules: BasicPrelude, CorePrelude build-depends: base >= 4 && < 5 , hashable , bytestring , text , transformers , containers , unordered-containers , vector , system-filepath >= 0.4 && < 0.5 , ReadArgs >= 1.2 && < 1.3 , lifted-base source-repository head type: git location: git://github.com/snoyberg/basic-prelude.git basic-prelude-0.3.4.0/CorePrelude.hs0000644000000000000000000001257512114614021015330 0ustar0000000000000000{-# 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 , putStrLn , getArgs , 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 , Set , HashSet , Seq , Vector , UVector , Unbox , 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 -- ** 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.catch , Control.Exception.Lifted.handle , Control.Exception.Lifted.bracket , Control.Exception.Lifted.onException , Control.Exception.Lifted.finally -- ** Files , F.FilePath , (F.) , (F.<.>) , F.hasExtension , F.basename , F.filename , F.directory -- ** Hashing , hash , hashWithSalt -- ** Print , Prelude.print -- ** 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 qualified Filesystem.Path.CurrentOS as F 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 Data.Map (Map) import Data.Set (Set) import Data.Sequence (Seq) import Data.HashMap.Strict (HashMap) import Data.HashSet (HashSet) import qualified ReadArgs import qualified System.Environment import qualified Data.Text import qualified Data.List #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 #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) putStrLn :: MonadIO m => Text -> m () putStrLn = liftIO . Data.Text.IO.putStrLn readArgs :: (MonadIO m, ReadArgs.ArgumentTuple a) => m a readArgs = liftIO ReadArgs.readArgs