prelude-compat (empty) → 0.0
raw patch · 7 files changed
+645/−0 lines, 7 filesdep +basesetup-changed
Dependencies added: base
Files
- LICENSE +30/−0
- Setup.lhs +8/−0
- catch/new/Catch.hs +6/−0
- catch/old/Catch.hs +1/−0
- prelude-compat.cabal +91/−0
- src/Data/List2010.hs +351/−0
- src/Prelude2010.hs +158/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2016, Henning Thielemann++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Henning Thielemann nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,8 @@+#!/usr/bin/env runghc++> module Main where++> import Distribution.Simple++> main :: IO ()+> main = defaultMain
+ catch/new/Catch.hs view
@@ -0,0 +1,6 @@+module Catch where++import System.IO.Error (catchIOError)++catch :: IO a -> (IOError -> IO a) -> IO a+catch = catchIOError
+ catch/old/Catch.hs view
@@ -0,0 +1,1 @@+module Catch (catch) where
+ prelude-compat.cabal view
@@ -0,0 +1,91 @@+Name: prelude-compat+Version: 0.0+Synopsis: Provide Prelude and Data.List with fixed content across GHC versions+Description:+ This package allows you to write warning-free code+ that compiles with versions of 'base' before and after AMP and FTP,+ that is, 'base' before and beginning with 4.8, respectively,+ and GHC before and beginning with 7.10, respectively.+ It serves three purposes:+ .+ * Prevent you from name clashes of FTP-Prelude+ with locally defined functions having names like '<*>', 'join', 'foldMap'.+ .+ * Prevent you from redundant import warnings+ if you manually import "Data.Monoid" or "Control.Applicative".+ .+ * Fix list functions to the list type, contrarily to the aim of the FTP.+ This way you are saved from @length (2,1) == 1@ and @maximum (2,1) == 1@,+ until you import @Data.Foldable@.+ .+ You should add+ .+ > import Prelude2010+ > import Prelude ()+ .+ to your modules.+ This way, you must change all affected modules.+ If you want to avoid this+ you may try the 'prelude2010' package+ or check whether it helps to add+ .+ > Default-Extensions: CPP, NoImplicitPrelude+ > CPP-Options: -DPrelude=Prelude2010+ .+ to your Cabal file.+ .+ In my opinion, this is the wrong way round.+ The presented Prelude2010 module should have been the one for GHC-7.10+ and the Prelude with added and generalized list functions+ should have been an additionally PreludeFTP,+ preferably exported by a separate package+ like all other alternate Prelude projects.+ But the purpose of the FTP was to save some import statements+ at the expense of blowing up the 'Foldable' class+ and prevent simple ways to write code that works+ with GHC version before and starting with GHC-7.10+ and that does not provoke warnings.+ .+ Related packages:+ .+ * 'base-compat': The opposite approach -+ Make future function definitions available in older GHC versions.+ .+ * 'haskell2010': Defines the Prelude for Haskell 2010.+ Unfortunately, 'haskell2010' is not available anymore since GHC-7.10,+ because of the AMP.+ .+ * 'numeric-prelude':+ It is intended to provide a refined numeric class hierarchy+ but it also provides a non-numeric subset of the Prelude+ that is more stable than the one of 'base'.+License: BSD3+License-File: LICENSE+Author: Henning Thielemann+Maintainer: haskell@henning-thielemann.de+Category: Prelude, Haskell2010+Build-Type: Simple+Cabal-Version: >=1.10+Tested-With: GHC==6.12.3, GHC==7.0.4, GHC==7.2.2+Tested-With: GHC==7.4.2, GHC==7.6.3, GHC==7.8.4, GHC==7.10.3++Source-Repository this+ Tag: 0.0+ Type: darcs+ Location: http://hub.darcs.net/thielema/prelude-compat++Source-Repository head+ Type: darcs+ Location: http://hub.darcs.net/thielema/prelude-compat++Library+ Exposed-Modules: Prelude2010, Data.List2010+ Other-Modules: Catch+ Build-Depends: base >=3 && <5+ Hs-Source-Dirs: src+ If impl(ghc>=7.2.2)+ Hs-Source-Dirs: catch/new+ Else+ Hs-Source-Dirs: catch/old+ Default-Language: Haskell98+ GHC-Options: -Wall
+ src/Data/List2010.hs view
@@ -0,0 +1,351 @@+module Data.List2010 where++import qualified Data.List as List+import Prelude hiding ((++))+++(!!) :: [a] -> Int -> a+(!!) = (List.!!)++infixr 5 ++++(++) :: [a] -> [a] -> [a]+(++) = (List.++)++infix 5 \\++(\\) :: Eq a => [a] -> [a] -> [a]+(\\) = (List.\\)++all :: (a -> Bool) -> [a] -> Bool+all = List.all++and :: [Bool] -> Bool+and = List.and++any :: (a -> Bool) -> [a] -> Bool+any = List.any++break :: (a -> Bool) -> [a] -> ([a], [a])+break = List.break++concat :: [[a]] -> [a]+concat = List.concat++concatMap :: (a -> [b]) -> [a] -> [b]+concatMap = List.concatMap++cycle :: [a] -> [a]+cycle = List.cycle++delete :: Eq a => a -> [a] -> [a]+delete = List.delete++deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]+deleteBy = List.deleteBy++deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]+deleteFirstsBy = List.deleteFirstsBy++drop :: Int -> [a] -> [a]+drop = List.drop++dropWhile :: (a -> Bool) -> [a] -> [a]+dropWhile = List.dropWhile++elem :: Eq a => a -> [a] -> Bool+elem = List.elem++elemIndex :: Eq a => a -> [a] -> Maybe Int+elemIndex = List.elemIndex++elemIndices :: Eq a => a -> [a] -> [Int]+elemIndices = List.elemIndices++filter :: (a -> Bool) -> [a] -> [a]+filter = List.filter++find :: (a -> Bool) -> [a] -> Maybe a+find = List.find++findIndex :: (a -> Bool) -> [a] -> Maybe Int+findIndex = List.findIndex++findIndices :: (a -> Bool) -> [a] -> [Int]+findIndices = List.findIndices++foldl :: (a -> b -> a) -> a -> [b] -> a+foldl = List.foldl++foldl' :: (a -> b -> a) -> a -> [b] -> a+foldl' = List.foldl'++foldl1 :: (a -> a -> a) -> [a] -> a+foldl1 = List.foldl1++foldl1' :: (a -> a -> a) -> [a] -> a+foldl1' = List.foldl1'++foldr :: (a -> b -> b) -> b -> [a] -> b+foldr = List.foldr++foldr1 :: (a -> a -> a) -> [a] -> a+foldr1 = List.foldr1++genericDrop :: Integral i => i -> [a] -> [a]+genericDrop = List.genericDrop++genericIndex :: Integral a => [b] -> a -> b+genericIndex = List.genericIndex++genericLength :: Num i => [b] -> i+genericLength = List.genericLength++genericReplicate :: Integral i => i -> a -> [a]+genericReplicate = List.genericReplicate++genericSplitAt :: Integral i => i -> [b] -> ([b], [b])+genericSplitAt = List.genericSplitAt++genericTake :: Integral i => i -> [a] -> [a]+genericTake = List.genericTake++group :: Eq a => [a] -> [[a]]+group = List.group++groupBy :: (a -> a -> Bool) -> [a] -> [[a]]+groupBy = List.groupBy++head :: [a] -> a+head = List.head++init :: [a] -> [a]+init = List.init++inits :: [a] -> [[a]]+inits = List.inits++insert :: Ord a => a -> [a] -> [a]+insert = List.insert++insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]+insertBy = List.insertBy++intercalate :: [a] -> [[a]] -> [a]+intercalate = List.intercalate++intersect :: Eq a => [a] -> [a] -> [a]+intersect = List.intersect++intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]+intersectBy = List.intersectBy++intersperse :: a -> [a] -> [a]+intersperse = List.intersperse++isInfixOf :: Eq a => [a] -> [a] -> Bool+isInfixOf = List.isInfixOf++isPrefixOf :: Eq a => [a] -> [a] -> Bool+isPrefixOf = List.isPrefixOf++isSuffixOf :: Eq a => [a] -> [a] -> Bool+isSuffixOf = List.isSuffixOf++iterate :: (a -> a) -> a -> [a]+iterate = List.iterate++last :: [a] -> a+last = List.last++length :: [a] -> Int+length = List.length++lines :: String -> [String]+lines = List.lines++lookup :: Eq a => a -> [(a, b)] -> Maybe b+lookup = List.lookup++map :: (a -> b) -> [a] -> [b]+map = List.map++mapAccumL :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])+mapAccumL = List.mapAccumL++mapAccumR :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])+mapAccumR = List.mapAccumR++maximum :: Ord a => [a] -> a+maximum = List.maximum++maximumBy :: (a -> a -> Ordering) -> [a] -> a+maximumBy = List.maximumBy++minimum :: Ord a => [a] -> a+minimum = List.minimum++minimumBy :: (a -> a -> Ordering) -> [a] -> a+minimumBy = List.minimumBy++notElem :: Eq a => a -> [a] -> Bool+notElem = List.notElem++nub :: Eq a => [a] -> [a]+nub = List.nub++nubBy :: (a -> a -> Bool) -> [a] -> [a]+nubBy = List.nubBy++null :: [a] -> Bool+null = List.null++or :: [Bool] -> Bool+or = List.or++partition :: (a -> Bool) -> [a] -> ([a], [a])+partition = List.partition++permutations :: [a] -> [[a]]+permutations = List.permutations++product :: Num a => [a] -> a+product = List.product++repeat :: a -> [a]+repeat = List.repeat++replicate :: Int -> a -> [a]+replicate = List.replicate++reverse :: [a] -> [a]+reverse = List.reverse++scanl :: (a -> b -> a) -> a -> [b] -> [a]+scanl = List.scanl++scanl1 :: (a -> a -> a) -> [a] -> [a]+scanl1 = List.scanl1++scanr :: (a -> b -> b) -> b -> [a] -> [b]+scanr = List.scanr++scanr1 :: (a -> a -> a) -> [a] -> [a]+scanr1 = List.scanr1++sort :: Ord a => [a] -> [a]+sort = List.sort++sortBy :: (a -> a -> Ordering) -> [a] -> [a]+sortBy = List.sortBy++span :: (a -> Bool) -> [a] -> ([a], [a])+span = List.span++splitAt :: Int -> [a] -> ([a], [a])+splitAt = List.splitAt++stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]+stripPrefix = List.stripPrefix++subsequences :: [a] -> [[a]]+subsequences = List.subsequences++sum :: Num a => [a] -> a+sum = List.sum++tail :: [a] -> [a]+tail = List.tail++tails :: [a] -> [[a]]+tails = List.tails++take :: Int -> [a] -> [a]+take = List.take++takeWhile :: (a -> Bool) -> [a] -> [a]+takeWhile = List.takeWhile++transpose :: [[a]] -> [[a]]+transpose = List.transpose++unfoldr :: (b -> Maybe (a, b)) -> b -> [a]+unfoldr = List.unfoldr++union :: Eq a => [a] -> [a] -> [a]+union = List.union++unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]+unionBy = List.unionBy++unlines :: [String] -> String+unlines = List.unlines++unwords :: [String] -> String+unwords = List.unwords++unzip :: [(a, b)] -> ([a], [b])+unzip = List.unzip++unzip3 :: [(a, b, c)] -> ([a], [b], [c])+unzip3 = List.unzip3++unzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d])+unzip4 = List.unzip4++unzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])+unzip5 = List.unzip5++unzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])+unzip6 = List.unzip6++unzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])+unzip7 = List.unzip7++words :: String -> [String]+words = List.words++zip :: [a] -> [b] -> [(a, b)]+zip = List.zip++zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]+zip3 = List.zip3++zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]+zip4 = List.zip4++zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)]+zip5 = List.zip5++zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)]+zip6 = List.zip6++zip7 ::+ [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] ->+ [(a, b, c, d, e, f, g)]+zip7 = List.zip7++zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]+zipWith = List.zipWith++zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]+zipWith3 = List.zipWith3++zipWith4 ::+ (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]+zipWith4 = List.zipWith4++zipWith5 ::+ (a -> b -> c -> d -> e -> f) ->+ [a] -> [b] -> [c] -> [d] -> [e] -> [f]+zipWith5 = List.zipWith5++zipWith6 ::+ (a -> b -> c -> d -> e -> f -> g) ->+ [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g]+zipWith6 = List.zipWith6++zipWith7 ::+ (a -> b -> c -> d -> e -> f -> g -> h) ->+ [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h]+zipWith7 = List.zipWith7
+ src/Prelude2010.hs view
@@ -0,0 +1,158 @@+module Prelude2010 (+ ($!),+ Catch.catch,+ gcd,+ ($),+ (&&),+ (.),+ (=<<),+ Bool (False, True),+ Bounded (minBound, maxBound),+ Char,+ Double,+ Either (Left, Right),+ Enum+ (succ, pred, toEnum, fromEnum,+ enumFrom, enumFromThen, enumFromTo, enumFromThenTo),+ Eq ((==), (/=)),+ FilePath,+ Float,+ Floating+ (pi, exp, sqrt, log, (**), logBase,+ sin, tan, cos, asin, atan, acos,+ sinh, tanh, cosh, asinh, atanh, acosh),+ Fractional ((/), recip, fromRational),+ Functor (fmap),+ IO,+ IOError,+ Int,+ Integer,+ Integral (quot, rem, div, mod, quotRem, divMod, toInteger),+ Maybe (Nothing, Just),+ Monad ((>>=), (>>), return, fail),+ Num ((+), (*), (-), negate, abs, signum, fromInteger),+ Ord (compare, (<), (>=), (>), (<=), max, min),+ Ordering (LT, EQ, GT),+ Rational,+ Read (readsPrec, readList),+ ReadS,+ Real (toRational),+ RealFloat+ (floatRadix, floatDigits, floatRange,+ decodeFloat, encodeFloat, exponent, significand, scaleFloat,+ isNaN, isInfinite, isDenormalized, isNegativeZero, isIEEE,+ atan2),+ RealFrac (properFraction, truncate, round, ceiling, floor),+ Show (showsPrec, show, showList),+ ShowS,+ String,+ (^),+ (^^),+ appendFile,+ asTypeOf,+ const,+ curry,+ either,+ error,+ even,+ flip,+ fromIntegral,+ fst,+ getChar,+ getContents,+ getLine,+ id,+ interact,+ ioError,+ lcm,+ lex,+ lines,+ mapM,+ mapM_,+ maximum,+ maybe,+ minimum,+ not,+ odd,+ otherwise,+ print,+ product,+ putChar,+ putStr,+ putStrLn,+ read,+ readFile,+ readIO,+ readLn,+ readParen,+ reads,+ realToFrac,+ seq,+ sequence,+ sequence_,+ showChar,+ showParen,+ showString,+ shows,+ snd,+ subtract,+ sum,+ uncurry,+ undefined,+ unlines,+ until,+ userError,+ writeFile,+ (||),++ (List.!!),+ (List.++),+ List.all,+ List.and,+ List.any,+ List.break,+ List.concat,+ List.concatMap,+ List.cycle,+ List.drop,+ List.dropWhile,+ List.elem,+ List.filter,+ List.foldl,+ List.foldl1,+ List.foldr,+ List.foldr1,+ List.head,+ List.init,+ List.iterate,+ List.last,+ List.length,+ List.lookup,+ List.map,+ List.notElem,+ List.null,+ List.or,+ List.repeat,+ List.replicate,+ List.reverse,+ List.scanl,+ List.scanl1,+ List.scanr,+ List.scanr1,+ List.span,+ List.splitAt,+ List.tail,+ List.take,+ List.takeWhile,+ List.unwords,+ List.unzip,+ List.unzip3,+ List.words,+ List.zip,+ List.zip3,+ List.zipWith,+ List.zipWith3,+ ) where++import qualified Data.List2010 as List+import qualified Catch