Merge pull request #7 from sdiehl/list-extras

all non-partial list functions
This commit is contained in:
Stephen Diehl
2016-04-13 18:56:58 -04:00
4 changed files with 71 additions and 10 deletions
+14
View File
@@ -2,9 +2,23 @@ Protolude
=========
[![Build Status](https://travis-ci.org/sdiehl/protolude.svg?branch=master)](https://travis-ci.org/sdiehl/protolude)
[![Hackage](https://img.shields.io/hackage/v/protolude.svg)](https://hackage.haskell.org/package/protolude)
A sensible starting Prelude for building custom Preludes.
Design points:
* Banishes String.
* Banishes partial functions.
* compiler warning on bottoms.
* Foldable / Traversable by default.
* Polymorphic string IO functions.
* Automatic string conversions.
* Type synonyms for major data structures.
* Basic monad transformers in scope by default.
* Unsafe functions are prefixed with "unsafe" in separate module.
* Compiler agnostic, GHC internal modules are abstracted out into Base.
Supports:
* GHC 7.6.1
+17 -6
View File
@@ -16,17 +16,21 @@ import GHC.Num as X
import GHC.Enum as X
import GHC.Real as X
import GHC.Float as X
import GHC.Show as X
import GHC.Show as X (
Show(..)
)
import GHC.Exts as X (
Constraint
, Ptr
, FunPtr
, the
)
import GHC.Base as X (
(++)
, seq
, asTypeOf
, ord
, maxInt
, minInt
)
import System.IO as X (
print
@@ -34,11 +38,17 @@ import System.IO as X (
, putStrLn
)
#if ( __GLASGOW_HASKELL__ >= 800 )
import GHC.Types as X hiding (Any)
#else
import GHC.Types as X
import GHC.Types as X (
Bool
, Char
, Int
, Word
, Ordering
, IO
#if ( __GLASGOW_HASKELL__ >= 710 )
, Coercible
#endif
)
infixr 0 $!
@@ -47,6 +57,7 @@ f $! x = let !vx = x in f vx
#endif
-- Simple Haskell Compiler
#if defined(__SHC_HASKELL__)
+7
View File
@@ -5,6 +5,7 @@ module List (
head,
ordNub,
sortOn,
list,
) where
import Data.List (sortBy)
@@ -12,6 +13,7 @@ import Data.Maybe (Maybe(..))
import Data.Ord (Ord, comparing)
import Data.Foldable (Foldable, foldr)
import Data.Function ((.))
import Data.Functor (fmap)
import Control.Monad (return)
import qualified Data.Set as Set
@@ -30,3 +32,8 @@ ordNub l = go Set.empty l
if x `Set.member` s
then go s xs
else x : go (Set.insert x s) xs
list :: [b] -> (a -> b) -> [a] -> [b]
list def f xs = case xs of
[] -> def
_ -> fmap f xs
+33 -4
View File
@@ -16,8 +16,6 @@ module Protolude (
LByteString,
) where
{-import qualified Prelude as P-}
import List as X
import Show as X
import Bool as X
@@ -105,6 +103,23 @@ import Data.List as X (
, reverse
, replicate
, take
, sortBy
, sort
, intersperse
, transpose
, subsequences
, permutations
, scanl
, scanr
, iterate
, repeat
, cycle
, unfoldr
, takeWhile
, dropWhile
, group
, inits
, tails
, zipWith
, zip
)
@@ -114,6 +129,18 @@ import Data.Sequence as X (Seq)
import Data.IntMap as X (IntMap)
import Data.IntSet as X (IntSet)
#if ( __GLASGOW_HASKELL__ >= 710 )
import Data.Proxy as X (
Proxy(..)
)
import Data.Void as X (
Void
, absurd
, vacuous
)
#endif
-- Monad transformers
import Control.Monad.State as X (
MonadState
@@ -166,7 +193,7 @@ import Data.Int as X
import Data.Bits as X
import Data.Word as X
import Data.Bool as X hiding (bool)
import Data.Char as X (Char)
import Data.Char as X (chr)
import Data.Maybe as X hiding (fromJust)
import Data.Either as X
import Data.Complex as X
@@ -180,7 +207,6 @@ import Data.Function as X (
, on
)
-- Genericss
import GHC.Generics (
Generic(..)
@@ -222,6 +248,8 @@ import Data.String.Conv as X (
, StringConv
)
import Data.String as X (IsString)
-- Printf
import Text.Printf as X (
PrintfArg
@@ -231,6 +259,7 @@ import Text.Printf as X (
-- IO
import System.Exit as X
--import System.Info as X
import System.Environment as X (getArgs)
import System.IO as X (
Handle