module ClassyPrelude
(
module CorePrelude
, Seq
, undefined
, empty
, append
, (++)
, module Control.Monad
, module Control.Concurrent.MVar.Lifted
, module Data.IORef.Lifted
, trace
, traceShow
, traceId
, traceM
, traceShowId
, traceShowM
, map
, concat
, concatMap
, filter
, find
, length
, singleton
, null
, pack
, unpack
, repack
, fromList
, toList
, mapM
, mapM_
, forM
, forM_
, replicateM
, replicateM_
, stripPrefix
, isPrefixOf
, stripSuffix
, isSuffixOf
, isInfixOf
, break
, span
, dropWhile
, takeWhile
, any
, all
, splitAt, take, drop
, fold
, words
, unwords
, lines
, unlines
, split
, reverse
, readMay
, replicate
, intercalate
, intersperse
, encodeUtf8
, decodeUtf8
, subsequences
, permutations
, partition
, zip, zip3, zip4, zip5, zip6, zip7
, unzip, unzip3, unzip4, unzip5, unzip6, unzip7
, zipWith, zipWith3, zipWith4, zipWith5, zipWith6, zipWith7
, nub
, nubBy
, sort
, sortBy
, sortWith
, group
, group'
, groupBy
, groupBy'
, groupWith
, cons
, uncons
, compareLength
, Foldable.sum
, Foldable.product
, repeat
, lookup
, insert
, delete
, member
, notMember
, elem
, notElem
, union
, difference
, (\\)
, intersection
, intersect
, unions
, show
, toLower
, toUpper
, toCaseFold
, toStrict
, fromStrict
, readFile
, writeFile
, getLine
, print
, toChunks
, fromChunks
, catchAny
, handleAny
, tryAny
, catchAnyDeep
, handleAnyDeep
, tryAnyDeep
, catchIO
, handleIO
, tryIO
, asByteString
, asLByteString
, asHashMap
, asHashSet
, asText
, asLText
, asList
, asMap
, asMaybe
, asSet
, asVector
, asUVector
, asIOException
, asSomeException
) where
import qualified Prelude
import Control.Monad (when, unless, void, liftM, ap, forever, join, sequence, sequence_, replicateM_)
import Control.Monad.Trans.Control (MonadBaseControl, liftBaseWith, restoreM)
import Control.Concurrent.Async (withAsync, waitCatch)
import Control.Concurrent.MVar.Lifted
import Data.IORef.Lifted
import Data.Monoid (Monoid)
import qualified Data.Monoid as Monoid
import Data.Foldable (Foldable)
import qualified Data.Foldable as Foldable
import Control.DeepSeq (NFData, ($!!))
import CorePrelude hiding (print, undefined)
import ClassyPrelude.Classes
import ClassyPrelude.ByteString ()
import ClassyPrelude.Char ()
import ClassyPrelude.Classes ()
import ClassyPrelude.FilePath ()
import ClassyPrelude.HashMap ()
import ClassyPrelude.HashSet ()
import ClassyPrelude.LByteString ()
import ClassyPrelude.LText ()
import ClassyPrelude.List ()
import ClassyPrelude.Map ()
import ClassyPrelude.Maybe ()
import ClassyPrelude.Set ()
import ClassyPrelude.Text ()
import ClassyPrelude.Vector ()
import ClassyPrelude.UVector ()
import ClassyPrelude.Sequence (Seq)
import Debug.Trace (trace, traceShow)
show :: (Show a, CanPack c Char) => a -> c
show = pack . Prelude.show
fromList :: CanPack c i => [i] -> c
fromList = pack
toList :: CanPack c i => c -> [i]
toList = unpack
readMay :: (Read b, CanPack a Char) => a -> Maybe b
readMay a =
case [x | (x, t) <- Prelude.reads (unpack a), null t] of
[x] -> Just x
_ -> Nothing
repack :: (CanPack a i, CanPack b i) => a -> b
repack = pack . unpack
append :: Monoid m => m -> m -> m
append = mappend
infixr 5 ++
(++) :: Monoid m => m -> m -> m
(++) = mappend
infixl 9 \\
(\\) :: CanDifference c => c -> c -> c
(\\) = difference
intersect :: CanIntersection c => c -> c -> c
intersect = intersection
unions :: (Foldable cc, Monoid c, CanUnion c) => cc c -> c
unions = Foldable.foldl' union Monoid.mempty
intercalate :: (CanConcat c i, CanIntersperse c i) => i -> c -> i
intercalate xs xss = concat (intersperse xs xss)
asByteString :: ByteString -> ByteString
asByteString = id
asLByteString :: LByteString -> LByteString
asLByteString = id
asHashMap :: HashMap k v -> HashMap k v
asHashMap = id
asHashSet :: HashSet a -> HashSet a
asHashSet = id
asText :: Text -> Text
asText = id
asLText :: LText -> LText
asLText = id
asList :: [a] -> [a]
asList = id
asMap :: Map k v -> Map k v
asMap = id
asMaybe :: Maybe a -> Maybe a
asMaybe = id
asSet :: Set a -> Set a
asSet = id
asVector :: Vector a -> Vector a
asVector = id
asUVector :: UVector a -> UVector a
asUVector = id
forM :: CanMapM ci mco m i o => ci -> (i -> m o) -> mco
forM = flip mapM
forM_ :: (Monad m, CanMapM_ ci i) => ci -> (i -> m o) -> m ()
forM_ = flip mapM_
elem :: CanMember c k => k -> c -> Bool
elem = member
notElem :: CanMember c k => k -> c -> Bool
notElem = notMember
print :: (Show a, MonadIO m) => a -> m ()
print = liftIO . Prelude.print
take :: CanSplitAt c i => i -> c -> c
take i c = Prelude.fst (splitAt i c)
drop :: CanSplitAt c i => i -> c -> c
drop i c = Prelude.snd (splitAt i c)
sortWith :: (CanSortBy c a, Ord b) => (a -> b) -> c -> c
sortWith f = sortBy $ comparing f
groupWith :: (CanGroupBy' c a, Eq b) => (a -> b) -> c -> [c]
groupWith f = groupBy' (\a b -> f a == f b)
undefined :: a
undefined = error "ClassyPrelude.undefined"
catchAny :: MonadBaseControl IO m => m a -> (SomeException -> m a) -> m a
catchAny action onE = tryAny action >>= either onE return
handleAny :: MonadBaseControl IO m => (SomeException -> m a) -> m a -> m a
handleAny = flip catchAny
tryAny :: MonadBaseControl IO m => m a -> m (Either SomeException a)
tryAny m =
liftBaseWith (\runInIO -> withAsync (runInIO m) waitCatch) >>=
either (return . Left) (liftM Right . restoreM)
catchAnyDeep :: (NFData a, MonadBaseControl IO m) => m a -> (SomeException -> m a) -> m a
catchAnyDeep action onE = tryAnyDeep action >>= either onE return
handleAnyDeep :: (NFData a, MonadBaseControl IO m) => (SomeException -> m a) -> m a -> m a
handleAnyDeep = flip catchAnyDeep
tryAnyDeep :: (NFData a, MonadBaseControl IO m)
=> m a
-> m (Either SomeException a)
tryAnyDeep m = tryAny $ do
x <- m
return $!! x
catchIO :: MonadBaseControl IO m => m a -> (IOException -> m a) -> m a
catchIO = catch
handleIO :: MonadBaseControl IO m => (IOException -> m a) -> m a -> m a
handleIO = handle
tryIO :: MonadBaseControl IO m => m a -> m (Either IOException a)
tryIO = try
asSomeException :: SomeException -> SomeException
asSomeException = id
asIOException :: IOException -> IOException
asIOException = id
traceId :: String -> String
traceId a = trace a a
traceM :: (Monad m) => String -> m ()
traceM string = trace string $ return ()
traceShowId :: (Show a) => a -> a
traceShowId a = trace (show a) a
traceShowM :: (Show a, Monad m) => a -> m ()
traceShowM = traceM . show