{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
module ClassyPrelude
(
module CorePrelude
, undefined
, (++)
, Semigroup (..)
, WrappedMonoid
, module Data.Functor
, module Control.Applicative
, (<&&>)
, (<||>)
, module Control.Monad
, whenM
, unlessM
, module UnliftIO
, orElseSTM
, module Data.Mutable
, module Control.Concurrent.STM.TBChan
, module Control.Concurrent.STM.TBMChan
, module Control.Concurrent.STM.TBMQueue
, module Control.Concurrent.STM.TMChan
, module Control.Concurrent.STM.TMQueue
, primToPrim
, primToIO
, primToST
, module Data.Primitive.MutVar
, trace
, traceShow
, traceId
, traceM
, traceShowId
, traceShowM
, module Data.Time
#if MIN_VERSION_time(1,10,0)
, parseTime
#endif
, Generic
, Identity (..)
, MonadReader
, ask
, asks
, ReaderT (..)
, Reader
, module Data.Foldable
, module Data.Traversable
, module Data.Bifunctor
, module Data.MonoTraversable
, module Data.MonoTraversable.Unprefixed
, module Data.Sequences
, module Data.Containers
, module Data.Builder
, module Data.NonNull
, toByteVector
, fromByteVector
, module Say
, yieldThread
, waitAsync
, pollAsync
, waitCatchAsync
, linkAsync
, link2Async
, map
, readMay
, zip, zip3, zip4, zip5, zip6, zip7
, unzip, unzip3, unzip4, unzip5, unzip6, unzip7
, zipWith, zipWith3, zipWith4, zipWith5, zipWith6, zipWith7
, hashNub
, ordNub
, ordNubBy
, sortWith
, Prelude.repeat
, (\\)
, intersect
, Show (..)
, tshow
, tlshow
, charToLower
, charToUpper
, readFile
, readFileUtf8
, writeFile
, writeFileUtf8
, hGetContents
, hPut
, hGetChunk
, print
, putChar
, putStr
, putStrLn
, getChar
, getLine
, getContents
, interact
, DList
, asDList
, applyDList
, module Control.DeepSeq
, asByteString
, asLByteString
, asHashMap
, asHashSet
, asText
, asLText
, asList
, asMap
, asIntMap
, asMaybe
, asSet
, asIntSet
, asVector
, asUVector
, asSVector
, asString
) where
import qualified Prelude
import Control.Applicative ((<**>),liftA,liftA2,liftA3,Alternative (..), optional)
import Data.Functor
import Control.Exception (assert)
import Control.DeepSeq (deepseq, ($!!), force, NFData (..))
import Control.Monad (when, unless, void, liftM, ap, forever, join, replicateM_, guard, MonadPlus (..), (=<<), (>=>), (<=<), liftM2, liftM3, liftM4, liftM5)
import qualified Control.Concurrent.STM as STM
import Data.Mutable
import Data.Traversable (Traversable (..), for, forM)
import Data.Foldable (Foldable)
import UnliftIO
import Data.Vector.Instances ()
import CorePrelude hiding
( putStr, putStrLn, print, undefined, (<>), catMaybes, first, second
, catchIOError
)
import Data.ChunkedZip
import qualified Data.Char as Char
import Data.Sequences
import Data.MonoTraversable
import Data.MonoTraversable.Unprefixed
import Data.MonoTraversable.Instances ()
import Data.Containers
import Data.Builder
import Data.NonNull
import qualified Data.ByteString
import qualified Data.Text.IO as TextIO
import qualified Data.Text.Lazy.IO as LTextIO
import Data.ByteString.Internal (ByteString (PS))
import Data.ByteString.Lazy.Internal (defaultChunkSize)
import Data.Vector.Storable (unsafeToForeignPtr, unsafeFromForeignPtr)
import qualified Debug.Trace as Trace
import Data.Semigroup (Semigroup (..), WrappedMonoid (..))
import Prelude (Show (..))
import Data.Time
( UTCTime (..)
, Day (..)
, toGregorian
, fromGregorian
, formatTime
#if !MIN_VERSION_time(1,10,0)
, parseTime
#endif
, parseTimeM
, getCurrentTime
, defaultTimeLocale
)
import qualified Data.Time as Time
import qualified Data.Set as Set
import qualified Data.Map as Map
import qualified Data.HashSet as HashSet
import GHC.Generics (Generic)
import GHC.Stack (HasCallStack)
import Control.Monad.Primitive (primToPrim, primToIO, primToST)
import Data.Primitive.MutVar
import Data.Functor.Identity (Identity (..))
import Control.Monad.Reader (MonadReader, ask, asks, ReaderT (..), Reader)
import Data.Bifunctor
import Data.DList (DList)
import qualified Data.DList as DList
import Say
import Control.Concurrent.STM.TBChan
import Control.Concurrent.STM.TBMChan
import Control.Concurrent.STM.TBMQueue
import Control.Concurrent.STM.TMChan
import Control.Concurrent.STM.TMQueue
import qualified Control.Concurrent
tshow :: Show a => a -> Text
tshow :: a -> Text
tshow = [Char] -> Text
forall seq. IsSequence seq => [Element seq] -> seq
fromList ([Char] -> Text) -> (a -> [Char]) -> a -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> [Char]
forall a. Show a => a -> [Char]
Prelude.show
tlshow :: Show a => a -> LText
tlshow :: a -> LText
tlshow = [Char] -> LText
forall seq. IsSequence seq => [Element seq] -> seq
fromList ([Char] -> LText) -> (a -> [Char]) -> a -> LText
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> [Char]
forall a. Show a => a -> [Char]
Prelude.show
charToLower :: Char -> Char
charToLower :: Char -> Char
charToLower = Char -> Char
Char.toLower
charToUpper :: Char -> Char
charToUpper :: Char -> Char
charToUpper = Char -> Char
Char.toUpper
readMay :: (Element c ~ Char, MonoFoldable c, Read a) => c -> Maybe a
readMay :: c -> Maybe a
readMay c
a =
case [a
x | (a
x, [Char]
t) <- ReadS a
forall a. Read a => ReadS a
Prelude.reads (c -> [Element c]
forall mono. MonoFoldable mono => mono -> [Element mono]
otoList c
a :: String), [Char] -> Bool
forall mono. MonoFoldable mono => mono -> Bool
onull [Char]
t] of
[a
x] -> a -> Maybe a
forall a. a -> Maybe a
Just a
x
[a]
_ -> Maybe a
forall a. Maybe a
Nothing
map :: Functor f => (a -> b) -> f a -> f b
map :: (a -> b) -> f a -> f b
map = (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
infixr 5 ++
(++) :: Monoid m => m -> m -> m
++ :: m -> m -> m
(++) = m -> m -> m
forall a. Monoid a => a -> a -> a
mappend
{-# INLINE (++) #-}
infixl 9 \\
(\\) :: SetContainer a => a -> a -> a
\\ :: a -> a -> a
(\\) = a -> a -> a
forall set. SetContainer set => set -> set -> set
difference
{-# INLINE (\\) #-}
intersect :: SetContainer a => a -> a -> a
intersect :: a -> a -> a
intersect = a -> a -> a
forall set. SetContainer set => set -> set -> set
intersection
{-# INLINE intersect #-}
asByteString :: ByteString -> ByteString
asByteString :: ByteString -> ByteString
asByteString = ByteString -> ByteString
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asLByteString :: LByteString -> LByteString
asLByteString :: LByteString -> LByteString
asLByteString = LByteString -> LByteString
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asHashMap :: HashMap k v -> HashMap k v
asHashMap :: HashMap k v -> HashMap k v
asHashMap = HashMap k v -> HashMap k v
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asHashSet :: HashSet a -> HashSet a
asHashSet :: HashSet a -> HashSet a
asHashSet = HashSet a -> HashSet a
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asText :: Text -> Text
asText :: Text -> Text
asText = Text -> Text
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asLText :: LText -> LText
asLText :: LText -> LText
asLText = LText -> LText
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asList :: [a] -> [a]
asList :: [a] -> [a]
asList = [a] -> [a]
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asMap :: Map k v -> Map k v
asMap :: Map k v -> Map k v
asMap = Map k v -> Map k v
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asIntMap :: IntMap v -> IntMap v
asIntMap :: IntMap v -> IntMap v
asIntMap = IntMap v -> IntMap v
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asMaybe :: Maybe a -> Maybe a
asMaybe :: Maybe a -> Maybe a
asMaybe = Maybe a -> Maybe a
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asSet :: Set a -> Set a
asSet :: Set a -> Set a
asSet = Set a -> Set a
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asIntSet :: IntSet -> IntSet
asIntSet :: IntSet -> IntSet
asIntSet = IntSet -> IntSet
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asVector :: Vector a -> Vector a
asVector :: Vector a -> Vector a
asVector = Vector a -> Vector a
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asUVector :: UVector a -> UVector a
asUVector :: UVector a -> UVector a
asUVector = UVector a -> UVector a
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asSVector :: SVector a -> SVector a
asSVector :: SVector a -> SVector a
asSVector = SVector a -> SVector a
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
asString :: [Char] -> [Char]
asString :: [Char] -> [Char]
asString = [Char] -> [Char]
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
print :: (Show a, MonadIO m) => a -> m ()
print :: a -> m ()
print = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (a -> IO ()) -> a -> m ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> IO ()
forall a. Show a => a -> IO ()
Prelude.print
sortWith :: (Ord a, IsSequence c) => (Element c -> a) -> c -> c
sortWith :: (Element c -> a) -> c -> c
sortWith Element c -> a
f = (Element c -> Element c -> Ordering) -> c -> c
forall seq.
SemiSequence seq =>
(Element seq -> Element seq -> Ordering) -> seq -> seq
sortBy ((Element c -> Element c -> Ordering) -> c -> c)
-> (Element c -> Element c -> Ordering) -> c -> c
forall a b. (a -> b) -> a -> b
$ (Element c -> a) -> Element c -> Element c -> Ordering
forall a b. Ord a => (b -> a) -> b -> b -> Ordering
comparing Element c -> a
f
undefined :: HasCallStack => a
undefined :: a
undefined = [Char] -> a
forall a. HasCallStack => [Char] -> a
error [Char]
"ClassyPrelude.undefined"
{-# DEPRECATED undefined "It is highly recommended that you either avoid partial functions or provide meaningful error messages" #-}
{-# WARNING trace "Leaving traces in the code" #-}
trace :: String -> a -> a
trace :: [Char] -> a -> a
trace = [Char] -> a -> a
forall a. [Char] -> a -> a
Trace.trace
{-# WARNING traceShow "Leaving traces in the code" #-}
traceShow :: Show a => a -> b -> b
traceShow :: a -> b -> b
traceShow = a -> b -> b
forall a b. Show a => a -> b -> b
Trace.traceShow
{-# WARNING traceId "Leaving traces in the code" #-}
traceId :: String -> String
traceId :: [Char] -> [Char]
traceId [Char]
a = [Char] -> [Char] -> [Char]
forall a. [Char] -> a -> a
Trace.trace [Char]
a [Char]
a
{-# WARNING traceM "Leaving traces in the code" #-}
traceM :: (Monad m) => String -> m ()
traceM :: [Char] -> m ()
traceM [Char]
string = [Char] -> m () -> m ()
forall a. [Char] -> a -> a
Trace.trace [Char]
string (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
{-# WARNING traceShowId "Leaving traces in the code" #-}
traceShowId :: (Show a) => a -> a
traceShowId :: a -> a
traceShowId a
a = [Char] -> a -> a
forall a. [Char] -> a -> a
Trace.trace (a -> [Char]
forall a. Show a => a -> [Char]
show a
a) a
a
{-# WARNING traceShowM "Leaving traces in the code" #-}
traceShowM :: (Show a, Monad m) => a -> m ()
traceShowM :: a -> m ()
traceShowM = [Char] -> m ()
forall (m :: * -> *). Monad m => [Char] -> m ()
traceM ([Char] -> m ()) -> (a -> [Char]) -> a -> m ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> [Char]
forall a. Show a => a -> [Char]
show
yieldThread :: MonadIO m => m ()
yieldThread :: m ()
yieldThread = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO ()
Control.Concurrent.yield
{-# INLINE yieldThread #-}
hashNub :: (Hashable a, Eq a) => [a] -> [a]
hashNub :: [a] -> [a]
hashNub = HashSet a -> [a] -> [a]
forall a. Hashable a => HashSet a -> [a] -> [a]
go HashSet a
forall a. HashSet a
HashSet.empty
where
go :: HashSet a -> [a] -> [a]
go HashSet a
_ [] = []
go HashSet a
s (a
x:[a]
xs) | a
x a -> HashSet a -> Bool
forall a. (Eq a, Hashable a) => a -> HashSet a -> Bool
`HashSet.member` HashSet a
s = HashSet a -> [a] -> [a]
go HashSet a
s [a]
xs
| Bool
otherwise = a
x a -> [a] -> [a]
forall a. a -> [a] -> [a]
: HashSet a -> [a] -> [a]
go (a -> HashSet a -> HashSet a
forall a. (Eq a, Hashable a) => a -> HashSet a -> HashSet a
HashSet.insert a
x HashSet a
s) [a]
xs
ordNub :: (Ord a) => [a] -> [a]
ordNub :: [a] -> [a]
ordNub = Set a -> [a] -> [a]
forall a. Ord a => Set a -> [a] -> [a]
go Set a
forall a. Set a
Set.empty
where
go :: Set a -> [a] -> [a]
go Set a
_ [] = []
go Set a
s (a
x:[a]
xs) | a
x a -> Set a -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` Set a
s = Set a -> [a] -> [a]
go Set a
s [a]
xs
| Bool
otherwise = a
x a -> [a] -> [a]
forall a. a -> [a] -> [a]
: Set a -> [a] -> [a]
go (a -> Set a -> Set a
forall a. Ord a => a -> Set a -> Set a
Set.insert a
x Set a
s) [a]
xs
ordNubBy :: (Ord b) => (a -> b) -> (a -> a -> Bool) -> [a] -> [a]
ordNubBy :: (a -> b) -> (a -> a -> Bool) -> [a] -> [a]
ordNubBy a -> b
p a -> a -> Bool
f = Map b [a] -> [a] -> [a]
go Map b [a]
forall k a. Map k a
Map.empty
where
go :: Map b [a] -> [a] -> [a]
go Map b [a]
_ [] = []
go Map b [a]
m (a
x:[a]
xs) = let b :: b
b = a -> b
p a
x in case b
b b -> Map b [a] -> Maybe [a]
forall k a. Ord k => k -> Map k a -> Maybe a
`Map.lookup` Map b [a]
m of
Maybe [a]
Nothing -> a
x a -> [a] -> [a]
forall a. a -> [a] -> [a]
: Map b [a] -> [a] -> [a]
go (b -> [a] -> Map b [a] -> Map b [a]
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert b
b [a
x] Map b [a]
m) [a]
xs
Just [a]
bucket
| (a -> a -> Bool) -> a -> [a] -> Bool
forall a. (a -> a -> Bool) -> a -> [a] -> Bool
elem_by a -> a -> Bool
f a
x [a]
bucket -> Map b [a] -> [a] -> [a]
go Map b [a]
m [a]
xs
| Bool
otherwise -> a
x a -> [a] -> [a]
forall a. a -> [a] -> [a]
: Map b [a] -> [a] -> [a]
go (b -> [a] -> Map b [a] -> Map b [a]
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert b
b (a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
bucket) Map b [a]
m) [a]
xs
elem_by :: (a -> a -> Bool) -> a -> [a] -> Bool
elem_by :: (a -> a -> Bool) -> a -> [a] -> Bool
elem_by a -> a -> Bool
_ a
_ [] = Bool
False
elem_by a -> a -> Bool
eq a
y (a
x:[a]
xs) = a
y a -> a -> Bool
`eq` a
x Bool -> Bool -> Bool
|| (a -> a -> Bool) -> a -> [a] -> Bool
forall a. (a -> a -> Bool) -> a -> [a] -> Bool
elem_by a -> a -> Bool
eq a
y [a]
xs
orElseSTM :: STM a -> STM a -> STM a
orElseSTM :: STM a -> STM a -> STM a
orElseSTM = STM a -> STM a -> STM a
forall a. STM a -> STM a -> STM a
STM.orElse
{-# INLINE orElseSTM #-}
whenM :: Monad m => m Bool -> m () -> m ()
whenM :: m Bool -> m () -> m ()
whenM m Bool
mbool m ()
action = m Bool
mbool m Bool -> (Bool -> m ()) -> m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Bool -> m () -> m ()) -> m () -> Bool -> m ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when m ()
action
unlessM :: Monad m => m Bool -> m () -> m ()
unlessM :: m Bool -> m () -> m ()
unlessM m Bool
mbool m ()
action = m Bool
mbool m Bool -> (Bool -> m ()) -> m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Bool -> m () -> m ()) -> m () -> Bool -> m ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless m ()
action
asDList :: DList a -> DList a
asDList :: DList a -> DList a
asDList = DList a -> DList a
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
{-# INLINE asDList #-}
applyDList :: DList a -> [a] -> [a]
applyDList :: DList a -> [a] -> [a]
applyDList = DList a -> [a] -> [a]
forall a. DList a -> [a] -> [a]
DList.apply
{-# INLINE applyDList #-}
infixr 3 <&&>
(<&&>) :: Applicative a => a Bool -> a Bool -> a Bool
<&&> :: a Bool -> a Bool -> a Bool
(<&&>) = (Bool -> Bool -> Bool) -> a Bool -> a Bool -> a Bool
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Bool -> Bool -> Bool
(&&)
{-# INLINE (<&&>) #-}
infixr 2 <||>
(<||>) :: Applicative a => a Bool -> a Bool -> a Bool
<||> :: a Bool -> a Bool -> a Bool
(<||>) = (Bool -> Bool -> Bool) -> a Bool -> a Bool -> a Bool
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Bool -> Bool -> Bool
(||)
{-# INLINE (<||>) #-}
toByteVector :: ByteString -> SVector Word8
toByteVector :: ByteString -> SVector Word8
toByteVector (PS ForeignPtr Word8
fptr Int
offset Int
idx) = ForeignPtr Word8 -> Int -> Int -> SVector Word8
forall a. Storable a => ForeignPtr a -> Int -> Int -> Vector a
unsafeFromForeignPtr ForeignPtr Word8
fptr Int
offset Int
idx
{-# INLINE toByteVector #-}
fromByteVector :: SVector Word8 -> ByteString
fromByteVector :: SVector Word8 -> ByteString
fromByteVector SVector Word8
v =
ForeignPtr Word8 -> Int -> Int -> ByteString
PS ForeignPtr Word8
fptr Int
offset Int
idx
where
(ForeignPtr Word8
fptr, Int
offset, Int
idx) = SVector Word8 -> (ForeignPtr Word8, Int, Int)
forall a. Storable a => Vector a -> (ForeignPtr a, Int, Int)
unsafeToForeignPtr SVector Word8
v
{-# INLINE fromByteVector #-}
waitAsync :: MonadIO m => Async a -> m a
waitAsync :: Async a -> m a
waitAsync = STM a -> m a
forall (m :: * -> *) a. MonadIO m => STM a -> m a
atomically (STM a -> m a) -> (Async a -> STM a) -> Async a -> m a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Async a -> STM a
forall a. Async a -> STM a
waitSTM
pollAsync :: MonadIO m => Async a -> m (Maybe (Either SomeException a))
pollAsync :: Async a -> m (Maybe (Either SomeException a))
pollAsync = STM (Maybe (Either SomeException a))
-> m (Maybe (Either SomeException a))
forall (m :: * -> *) a. MonadIO m => STM a -> m a
atomically (STM (Maybe (Either SomeException a))
-> m (Maybe (Either SomeException a)))
-> (Async a -> STM (Maybe (Either SomeException a)))
-> Async a
-> m (Maybe (Either SomeException a))
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Async a -> STM (Maybe (Either SomeException a))
forall a. Async a -> STM (Maybe (Either SomeException a))
pollSTM
waitCatchAsync :: MonadIO m => Async a -> m (Either SomeException a)
waitCatchAsync :: Async a -> m (Either SomeException a)
waitCatchAsync = Async a -> m (Either SomeException a)
forall (m :: * -> *) a.
MonadIO m =>
Async a -> m (Either SomeException a)
waitCatch
linkAsync :: MonadIO m => Async a -> m ()
linkAsync :: Async a -> m ()
linkAsync = Async a -> m ()
forall (m :: * -> *) a. MonadIO m => Async a -> m ()
UnliftIO.link
link2Async :: MonadIO m => Async a -> Async b -> m ()
link2Async :: Async a -> Async b -> m ()
link2Async Async a
a = Async a -> Async b -> m ()
forall (m :: * -> *) a b. MonadIO m => Async a -> Async b -> m ()
UnliftIO.link2 Async a
a
readFile :: MonadIO m => FilePath -> m ByteString
readFile :: [Char] -> m ByteString
readFile = IO ByteString -> m ByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ByteString -> m ByteString)
-> ([Char] -> IO ByteString) -> [Char] -> m ByteString
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [Char] -> IO ByteString
Data.ByteString.readFile
readFileUtf8 :: MonadIO m => FilePath -> m Text
readFileUtf8 :: [Char] -> m Text
readFileUtf8 = (ByteString -> Text) -> m ByteString -> m Text
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ByteString -> Text
forall textual binary. Utf8 textual binary => binary -> textual
decodeUtf8 (m ByteString -> m Text)
-> ([Char] -> m ByteString) -> [Char] -> m Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [Char] -> m ByteString
forall (m :: * -> *). MonadIO m => [Char] -> m ByteString
readFile
writeFile :: MonadIO m => FilePath -> ByteString -> m ()
writeFile :: [Char] -> ByteString -> m ()
writeFile [Char]
fp = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (ByteString -> IO ()) -> ByteString -> m ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [Char] -> ByteString -> IO ()
Data.ByteString.writeFile [Char]
fp
writeFileUtf8 :: MonadIO m => FilePath -> Text -> m ()
writeFileUtf8 :: [Char] -> Text -> m ()
writeFileUtf8 [Char]
fp = [Char] -> ByteString -> m ()
forall (m :: * -> *). MonadIO m => [Char] -> ByteString -> m ()
writeFile [Char]
fp (ByteString -> m ()) -> (Text -> ByteString) -> Text -> m ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Text -> ByteString
forall textual binary. Utf8 textual binary => textual -> binary
encodeUtf8
hGetContents :: MonadIO m => Handle -> m ByteString
hGetContents :: Handle -> m ByteString
hGetContents = IO ByteString -> m ByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ByteString -> m ByteString)
-> (Handle -> IO ByteString) -> Handle -> m ByteString
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Handle -> IO ByteString
Data.ByteString.hGetContents
hPut :: MonadIO m => Handle -> ByteString -> m ()
hPut :: Handle -> ByteString -> m ()
hPut Handle
h = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (ByteString -> IO ()) -> ByteString -> m ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Handle -> ByteString -> IO ()
Data.ByteString.hPut Handle
h
hGetChunk :: MonadIO m => Handle -> m ByteString
hGetChunk :: Handle -> m ByteString
hGetChunk = IO ByteString -> m ByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ByteString -> m ByteString)
-> (Handle -> IO ByteString) -> Handle -> m ByteString
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Handle -> Int -> IO ByteString) -> Int -> Handle -> IO ByteString
forall a b c. (a -> b -> c) -> b -> a -> c
flip Handle -> Int -> IO ByteString
Data.ByteString.hGetSome Int
defaultChunkSize
putChar :: MonadIO m => Char -> m ()
putChar :: Char -> m ()
putChar = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (Char -> IO ()) -> Char -> m ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Char -> IO ()
Prelude.putChar
putStr :: MonadIO m => Text -> m ()
putStr :: Text -> m ()
putStr = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (Text -> IO ()) -> Text -> m ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Text -> IO ()
TextIO.putStr
putStrLn :: MonadIO m => Text -> m ()
putStrLn :: Text -> m ()
putStrLn = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (Text -> IO ()) -> Text -> m ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Text -> IO ()
TextIO.putStrLn
getChar :: MonadIO m => m Char
getChar :: m Char
getChar = IO Char -> m Char
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO Char
Prelude.getChar
getLine :: MonadIO m => m Text
getLine :: m Text
getLine = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO Text
TextIO.getLine
getContents :: MonadIO m => m LText
getContents :: m LText
getContents = IO LText -> m LText
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO LText
LTextIO.getContents
interact :: MonadIO m => (LText -> LText) -> m ()
interact :: (LText -> LText) -> m ()
interact = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ())
-> ((LText -> LText) -> IO ()) -> (LText -> LText) -> m ()
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (LText -> LText) -> IO ()
LTextIO.interact
#if MIN_VERSION_time(1,10,0)
parseTime
:: Time.ParseTime t
=> Time.TimeLocale
-> String
-> String
-> Maybe t
parseTime = parseTimeM True
#endif