classy-prelude-0.5.7: A typeclass-based Prelude.

Safe HaskellNone

ClassyPrelude

Contents

Synopsis

CorePrelude

data Seq a

General-purpose finite sequences.

Instances

Monad Seq 
Functor Seq 
Typeable1 Seq 
MonadPlus Seq 
Foldable Seq 
Traversable Seq 
Eq a => Eq (Seq a) 
Data a => Data (Seq a) 
Ord a => Ord (Seq a) 
Read a => Read (Seq a) 
Show a => Show (Seq a) 
Monoid (Seq a) 
NFData a => NFData (Seq a) 
CanEmpty (Seq a) 
CanReverse (Seq a) 
Eq a => CanStripSuffix (Seq a) 
Eq a => CanStripPrefix (Seq a) 
CanNull (Seq a) 
CanUncons (Seq a) a 
CanCons (Seq a) a 
Ord a => CanSort (Seq a) a 
CanSortBy (Seq a) a 
CanPartition (Seq a) a 
Monoid m => CanConcat (Seq m) m 
CanFind (Seq a) a 
CanSplitAt (Seq a) Int 
CanAny (Seq a) a 
CanBreak (Seq a) a 
Eq x => CanMember (Seq x) x 
CanMapM_ (Seq a) a 
CanIntersperse (Seq a) a 
CanPack (Seq a) a 
CanSingleton (Seq a) a 
CanLength (Seq a) Int 
CanFilterM (Seq a) a 
CanFilter (Seq a) a 
CanReplicate (Seq a) a Int 
CanFold (Seq a) a accum 
CanReplicateM (Seq a) a Int 
CanZip (Seq a) a (Seq b) b Seq 
CanZipWith (Seq a) a (Seq b) b (Seq c) c 
CanZip3 (Seq a) a (Seq b) b (Seq c) c Seq 
CanZipWith3 (Seq a) a (Seq b) b (Seq c) c (Seq d) d 
CanZip4 (Seq a) a (Seq b) b (Seq c) c (Seq d) d Seq 
CanZipWith4 (Seq a) a (Seq b) b (Seq c) c (Seq d) d (Seq e) e 
CanMap (Seq a) (Seq b) a b 
Monad m => CanMapM (Seq i) (m (Seq o)) m i o 
CanConcatMap (Seq a) (Seq b) a (Seq b) 

undefined :: a

Deprecated: It is highly recommended that you either avoid partial functions or provide meaningful error messages

We define our own undefined which is marked as deprecated. This makes it useful to use during development, but let's you more easily getting notification if you accidentally ship partial code in production.

The classy prelude recommendation for when you need to really have a partial function in production is to use error with a very descriptive message so that, in case an exception is thrown, you get more information than Prelude.undefined.

Since 0.5.5

Standard

Monoid

empty :: CanEmpty a => a

append :: Monoid m => m -> m -> m

(++) :: Monoid m => m -> m -> m

Monad

Mutable references

Non-standard

List-like classes

map :: CanMap ci co i o => (i -> o) -> ci -> co

concat :: CanConcat c i => c -> i

concatMap :: CanConcatMap ci co i o => (i -> o) -> ci -> co

filter :: CanFilter c i => (i -> Bool) -> c -> c

find :: CanFind c i => (i -> Bool) -> c -> Maybe i

length :: CanLength c len => c -> len

singleton :: CanSingleton c i => i -> c

null :: CanNull c => c -> Bool

pack :: CanPack c i => [i] -> c

unpack :: CanPack c i => c -> [i]

repack :: (CanPack a i, CanPack b i) => a -> b

Repack from one type to another, dropping to a list in the middle.

repack = pack . unpack.

fromList :: CanPack c i => [i] -> c

toList :: CanPack c i => c -> [i]

mapM :: CanMapM ci mco m i o => (i -> m o) -> ci -> mco

mapM_ :: (CanMapM_ ci i, Monad m) => (i -> m o) -> ci -> m ()

forM :: CanMapM ci mco m i o => ci -> (i -> m o) -> mco

forM_ :: (Monad m, CanMapM_ ci i) => ci -> (i -> m o) -> m ()

replicateM :: (CanReplicateM c i len, Monad m) => len -> m i -> m c

replicateM_ :: (CanReplicateM_ i len, Monad m) => len -> m i -> m ()

stripPrefix :: CanStripPrefix a => a -> a -> Maybe a

isPrefixOf :: CanStripPrefix a => a -> a -> Bool

stripSuffix :: CanStripSuffix a => a -> a -> Maybe a

isSuffixOf :: CanStripSuffix a => a -> a -> Bool

isInfixOf :: CanIsInfixOf a => a -> a -> Bool

break :: CanBreak c i => (i -> Bool) -> c -> (c, c)

span :: CanBreak c i => (i -> Bool) -> c -> (c, c)

dropWhile :: CanBreak c i => (i -> Bool) -> c -> c

takeWhile :: CanBreak c i => (i -> Bool) -> c -> c

any :: CanAny c i => (i -> Bool) -> c -> Bool

all :: CanAny c i => (i -> Bool) -> c -> Bool

splitAt :: CanSplitAt c i => i -> c -> (c, c)

take :: CanSplitAt c i => i -> c -> c

drop :: CanSplitAt c i => i -> c -> c

fold :: CanFold c i accum => (accum -> i -> accum) -> accum -> c -> accum

Strict left fold.

words :: CanWords t => t -> [t]

unwords :: CanWords t => [t] -> t

lines :: CanLines t => t -> [t]

unlines :: CanUnlines t => [t] -> t

split :: CanSplit c i => (i -> Bool) -> c -> [c]

reverse :: CanReverse a => a -> a

readMay :: (Read b, CanPack a Char) => a -> Maybe b

replicate :: CanReplicate a i len => len -> i -> a

intercalate :: (CanConcat c i, CanIntersperse c i) => i -> c -> i

intersperse :: CanIntersperse c i => i -> c -> c

encodeUtf8 :: CanEncodeUtf8 ci co => ci -> co

decodeUtf8 :: CanDecodeUtf8 ci co => ci -> co

subsequences :: CanPack c i => c -> [c]

permutations :: CanPack c i => c -> [c]

partition :: CanPartition c i => (i -> Bool) -> c -> (c, c)

zip :: CanZip c1 i1 c2 i2 t => c1 -> c2 -> t (i1, i2)

zip3 :: CanZip3 c1 i1 c2 i2 c3 i3 t => c1 -> c2 -> c3 -> t (i1, i2, i3)

zip4 :: CanZip4 c1 i1 c2 i2 c3 i3 c4 i4 t => c1 -> c2 -> c3 -> c4 -> t (i1, i2, i3, i4)

zip5 :: CanZip5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 t => c1 -> c2 -> c3 -> c4 -> c5 -> t (i1, i2, i3, i4, i5)

zip6 :: CanZip6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 t => c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> t (i1, i2, i3, i4, i5, i6)

zip7 :: CanZip7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 t => c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7 -> t (i1, i2, i3, i4, i5, i6, i7)

unzip :: CanUnzip c1 i1 c2 i2 t => t (i1, i2) -> (c1, c2)

unzip3 :: CanUnzip3 c1 i1 c2 i2 c3 i3 t => t (i1, i2, i3) -> (c1, c2, c3)

unzip4 :: CanUnzip4 c1 i1 c2 i2 c3 i3 c4 i4 t => t (i1, i2, i3, i4) -> (c1, c2, c3, c4)

unzip5 :: CanUnzip5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 t => t (i1, i2, i3, i4, i5) -> (c1, c2, c3, c4, c5)

unzip6 :: CanUnzip6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 t => t (i1, i2, i3, i4, i5, i6) -> (c1, c2, c3, c4, c5, c6)

unzip7 :: CanUnzip7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 t => t (i1, i2, i3, i4, i5, i6, i7) -> (c1, c2, c3, c4, c5, c6, c7)

zipWith :: CanZipWith c1 i1 c2 i2 c3 i3 => (i1 -> i2 -> i3) -> c1 -> c2 -> c3

zipWith3 :: CanZipWith3 c1 i1 c2 i2 c3 i3 c4 i4 => (i1 -> i2 -> i3 -> i4) -> c1 -> c2 -> c3 -> c4

zipWith4 :: CanZipWith4 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 => (i1 -> i2 -> i3 -> i4 -> i5) -> c1 -> c2 -> c3 -> c4 -> c5

zipWith5 :: CanZipWith5 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 => (i1 -> i2 -> i3 -> i4 -> i5 -> i6) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6

zipWith6 :: CanZipWith6 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 => (i1 -> i2 -> i3 -> i4 -> i5 -> i6 -> i7) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7

zipWith7 :: CanZipWith7 c1 i1 c2 i2 c3 i3 c4 i4 c5 i5 c6 i6 c7 i7 c8 i8 => (i1 -> i2 -> i3 -> i4 -> i5 -> i6 -> i7 -> i8) -> c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7 -> c8

nub :: (CanNubBy c i, Ord i, CanNubBy c i) => c -> c

nubBy :: CanNubBy c i => (i -> i -> Bool) -> c -> c

sort :: CanSort c a => c -> c

sortBy :: CanSortBy c a => (a -> a -> Ordering) -> c -> c

sortWith :: (CanSortBy c a, Ord b) => (a -> b) -> c -> c

Sort elements using the user supplied function to project something out of each element. Inspired by http://hackage.haskell.org/packages/archive/base/latest/doc/html/GHC-Exts.html#v:sortWith.

group :: CanGroup c a => c -> [c]

groupBy :: CanGroupBy c a => (a -> a -> Bool) -> c -> [c]

groupWith :: (CanGroupBy c a, Eq b) => (a -> b) -> c -> [c]

The groupWith function uses the user supplied function which projects an element out of every list element in order to first sort the input list and then to form groups by equality on these projected elements

Inspired by http://hackage.haskell.org/packages/archive/base/latest/doc/html/GHC-Exts.html#v:groupWith

cons :: CanCons c a => a -> c -> c

uncons :: CanUncons c a => c -> Maybe (a, c)

compareLength :: (CanCompareLength c, Integral l) => c -> l -> Ordering

This is a more effective alternative to statements like i >= length xs for types having an O(n) complexity of length operation like list or Text. It does not traverse the whole data structure if the value being compared to is lesser.

sum :: (Foldable t, Num a) => t a -> a

The sum function computes the sum of the numbers of a structure.

product :: (Foldable t, Num a) => t a -> a

The product function computes the product of the numbers of a structure.

repeat :: CanRepeat c a => a -> c

Map-like

lookup :: CanLookup c k v => k -> c -> Maybe v

insert :: CanInsert f => f

delete :: CanDelete f => f

Set-like

member :: CanMember c k => k -> c -> Bool

notMember :: CanMember c k => k -> c -> Bool

elem :: CanMember c k => k -> c -> Bool

An alias for member

notElem :: CanMember c k => k -> c -> Bool

An alias for notMember

union :: CanUnion c => c -> c -> c

difference :: CanDifference c => c -> c -> c

(\\) :: CanDifference c => c -> c -> c

An alias for difference.

intersection :: CanIntersection c => c -> c -> c

intersect :: CanIntersection c => c -> c -> c

An alias for intersection.

unions :: (Foldable cc, Monoid c, CanUnion c) => cc c -> c

Text-like

show :: (Show a, CanPack c Char) => a -> c

toLower :: CanToLower a => a -> a

toUpper :: CanToUpper a => a -> a

toCaseFold :: CanToCaseFold a => a -> a

toStrict :: CanToStrict a b => a -> b

fromStrict :: CanToStrict a b => b -> a

IO

readFile :: (CanReadFile a, MonadIO m) => FilePath -> m a

writeFile :: (CanWriteFile a, MonadIO m) => FilePath -> a -> m ()

print :: (Show a, MonadIO m) => a -> m ()

Chunking

toChunks :: CanToChunks c i => c -> [i]

fromChunks :: CanToChunks c i => [i] -> c

Exceptions

catchAny :: MonadBaseControl IO m => m a -> (SomeException -> m a) -> m a

A version of catch which is specialized for any exception. This simplifies usage as no explicit type signatures are necessary.

Since 0.5.6

handleAny :: MonadBaseControl IO m => (SomeException -> m a) -> m a -> m a

A version of handle which is specialized for any exception. This simplifies usage as no explicit type signatures are necessary.

Since 0.5.6

tryAny :: MonadBaseControl IO m => m a -> m (Either SomeException a)

A version of try which is specialized for any exception. This simplifies usage as no explicit type signatures are necessary.

Since 0.5.6

catchIO :: MonadBaseControl IO m => m a -> (IOException -> m a) -> m a

A version of catch which is specialized for IO exceptions. This simplifies usage as no explicit type signatures are necessary.

Since 0.5.6

handleIO :: MonadBaseControl IO m => (IOException -> m a) -> m a -> m a

A version of handle which is specialized for IO exceptions. This simplifies usage as no explicit type signatures are necessary.

Since 0.5.6

tryIO :: MonadBaseControl IO m => m a -> m (Either IOException a)

A version of try which is specialized for IO exceptions. This simplifies usage as no explicit type signatures are necessary.

Since 0.5.6

Force types

Helper functions for situations where type inferer gets confused.

asHashMap :: HashMap k v -> HashMap k v

asList :: [a] -> [a]

asMap :: Map k v -> Map k v

asMaybe :: Maybe a -> Maybe a

asSet :: Set a -> Set a