Safe Haskell | None |
---|
ClassyPrelude
Contents
- module CorePrelude
- data Seq a
- undefined :: a
- empty :: CanEmpty a => a
- append :: Monoid m => m -> m -> m
- (++) :: Monoid m => m -> m -> m
- module Control.Monad
- module Control.Concurrent.MVar.Lifted
- module Data.IORef.Lifted
- 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
- 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
- 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
- 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]
- cons :: CanCons c a => a -> c -> c
- uncons :: CanUncons c a => c -> Maybe (a, c)
- compareLength :: (CanCompareLength c, Integral l) => c -> l -> Ordering
- sum :: (Foldable t, Num a) => t a -> a
- product :: (Foldable t, Num a) => t a -> a
- repeat :: CanRepeat c a => a -> c
- lookup :: CanLookup c k v => k -> c -> Maybe v
- insert :: CanInsert f => f
- delete :: CanDelete f => f
- member :: CanMember c k => k -> c -> Bool
- notMember :: CanMember c k => k -> c -> Bool
- elem :: CanMember c k => k -> c -> Bool
- notElem :: CanMember c k => k -> c -> Bool
- union :: CanUnion c => c -> c -> c
- difference :: CanDifference c => c -> c -> c
- (\\) :: CanDifference c => c -> c -> c
- intersection :: CanIntersection c => c -> c -> c
- intersect :: CanIntersection c => c -> c -> c
- unions :: (Foldable cc, Monoid c, CanUnion c) => cc c -> c
- 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
- readFile :: (CanReadFile a, MonadIO m) => FilePath -> m a
- writeFile :: (CanWriteFile a, MonadIO m) => FilePath -> a -> m ()
- getLine :: CanGetLine a => a
- print :: (Show a, MonadIO m) => a -> m ()
- toChunks :: CanToChunks c i => c -> [i]
- fromChunks :: CanToChunks c i => [i] -> c
- catchAny :: MonadBaseControl IO m => m a -> (SomeException -> m a) -> m a
- handleAny :: MonadBaseControl IO m => (SomeException -> m a) -> m a -> m a
- tryAny :: MonadBaseControl IO m => m a -> m (Either SomeException a)
- catchIO :: MonadBaseControl IO m => m a -> (IOException -> m a) -> m a
- handleIO :: MonadBaseControl IO m => (IOException -> m a) -> m a -> m a
- tryIO :: MonadBaseControl IO m => m a -> m (Either IOException a)
- asByteString :: ByteString -> ByteString
- asLByteString :: LByteString -> LByteString
- asHashMap :: HashMap k v -> HashMap k v
- asHashSet :: HashSet a -> HashSet a
- asText :: Text -> Text
- asLText :: LText -> LText
- asList :: [a] -> [a]
- asMap :: Map k v -> Map k v
- asMaybe :: Maybe a -> Maybe a
- asSet :: Set a -> Set a
- asVector :: Vector a -> Vector a
- asIOException :: IOException -> IOException
- asSomeException :: SomeException -> SomeException
CorePrelude
module CorePrelude
data Seq a
General-purpose finite sequences.
Instances
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
Monad
module Control.Monad
Mutable references
module Data.IORef.Lifted
Non-standard
List-like classes
concatMap :: CanConcatMap ci co i o => (i -> o) -> ci -> co
singleton :: CanSingleton c i => i -> c
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
.
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
splitAt :: CanSplitAt c i => i -> c -> (c, c)
take :: CanSplitAt c i => i -> c -> c
drop :: CanSplitAt c i => i -> c -> c
unlines :: CanUnlines t => [t] -> t
reverse :: CanReverse a => a -> a
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)
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)
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
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.
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
compareLength :: (CanCompareLength c, Integral l) => c -> l -> Ordering
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.
Map-like
Set-like
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
.
Text-like
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 ()
getLine :: CanGetLine a => a
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.
asByteString :: ByteString -> ByteString
asList :: [a] -> [a]
asIOException :: IOException -> IOException
Since 0.5.6
asSomeException :: SomeException -> SomeException
Since 0.5.6