Safe Haskell | None |
---|---|
Language | Haskell2010 |
ClassyPrelude
Synopsis
- seq :: a -> b -> b
- fst :: (a, b) -> a
- snd :: (a, b) -> b
- otherwise :: Bool
- ($) :: (a -> b) -> a -> b
- fromIntegral :: (Integral a, Num b) => a -> b
- realToFrac :: (Real a, Fractional b) => a -> b
- class Bounded a where
- class Enum a where
- class Eq a where
- class Fractional a => Floating a where
- class Num a => Fractional a where
- class (Real a, Enum a) => Integral a where
- class Applicative m => Monad (m :: * -> *) where
- class Functor (f :: * -> *) where
- class Num a where
- class Eq a => Ord a where
- class Read a
- class (Num a, Ord a) => Real a where
- class (RealFrac a, Floating a) => RealFloat a where
- class (Real a, Fractional a) => RealFrac a where
- class Show a
- class Typeable (a :: k)
- class IsString a where
- class Functor f => Applicative (f :: * -> *) where
- class Foldable (t :: * -> *)
- class (Functor t, Foldable t) => Traversable (t :: * -> *)
- class Semigroup a => Monoid a where
- data Bool
- data Char
- data Double
- data Float
- data Int
- data Int32
- data Int64
- data Integer
- data Maybe a
- data Ordering
- type Rational = Ratio Integer
- data IO a
- data Word
- data Word8
- data Word32
- data Word64
- data Either a b
- either :: (a -> c) -> (b -> c) -> Either a b -> c
- class Monad m => MonadIO (m :: * -> *) where
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- (***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c')
- (&&&) :: Arrow a => a b c -> a b c' -> a b (c, c')
- annotateIOError :: IOError -> String -> Maybe Handle -> Maybe FilePath -> IOError
- modifyIOError :: (IOError -> IOError) -> IO a -> IO a
- ioeSetFileName :: IOError -> FilePath -> IOError
- ioeSetHandle :: IOError -> Handle -> IOError
- ioeSetLocation :: IOError -> String -> IOError
- ioeSetErrorString :: IOError -> String -> IOError
- ioeSetErrorType :: IOError -> IOErrorType -> IOError
- ioeGetFileName :: IOError -> Maybe FilePath
- ioeGetHandle :: IOError -> Maybe Handle
- ioeGetLocation :: IOError -> String
- ioeGetErrorString :: IOError -> String
- ioeGetErrorType :: IOError -> IOErrorType
- isUserErrorType :: IOErrorType -> Bool
- isPermissionErrorType :: IOErrorType -> Bool
- isIllegalOperationErrorType :: IOErrorType -> Bool
- isEOFErrorType :: IOErrorType -> Bool
- isFullErrorType :: IOErrorType -> Bool
- isAlreadyInUseErrorType :: IOErrorType -> Bool
- isDoesNotExistErrorType :: IOErrorType -> Bool
- isAlreadyExistsErrorType :: IOErrorType -> Bool
- userErrorType :: IOErrorType
- permissionErrorType :: IOErrorType
- illegalOperationErrorType :: IOErrorType
- eofErrorType :: IOErrorType
- fullErrorType :: IOErrorType
- alreadyInUseErrorType :: IOErrorType
- doesNotExistErrorType :: IOErrorType
- alreadyExistsErrorType :: IOErrorType
- isUserError :: IOError -> Bool
- isPermissionError :: IOError -> Bool
- isIllegalOperation :: IOError -> Bool
- isEOFError :: IOError -> Bool
- isFullError :: IOError -> Bool
- isAlreadyInUseError :: IOError -> Bool
- isDoesNotExistError :: IOError -> Bool
- isAlreadyExistsError :: IOError -> Bool
- mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> IOError
- tryIOError :: IO a -> IO (Either IOError a)
- ioError :: IOError -> IO a
- data IOErrorType
- type FilePath = String
- userError :: String -> IOError
- data IOException
- type IOError = IOException
- class (Typeable e, Show e) => Exception e where
- asum :: (Foldable t, Alternative f) => t (f a) -> f a
- partitionEithers :: [Either a b] -> ([a], [b])
- rights :: [Either a b] -> [b]
- lefts :: [Either a b] -> [a]
- comparing :: Ord a => (b -> a) -> b -> b -> Ordering
- newtype Down a = Down a
- id :: Category cat => cat a a
- (.) :: Category cat => cat b c -> cat a b -> cat a c
- class Storable a
- bool :: a -> a -> Bool -> a
- on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- (^^) :: (Fractional a, Integral b) => a -> b -> a
- (^) :: (Num a, Integral b) => a -> b -> a
- odd :: Integral a => a -> Bool
- even :: Integral a => a -> Bool
- mapMaybe :: (a -> Maybe b) -> [a] -> [b]
- listToMaybe :: [a] -> Maybe a
- maybeToList :: Maybe a -> [a]
- fromMaybe :: a -> Maybe a -> a
- isNothing :: Maybe a -> Bool
- isJust :: Maybe a -> Bool
- maybe :: b -> (a -> b) -> Maybe a -> b
- swap :: (a, b) -> (b, a)
- uncurry :: (a -> b -> c) -> (a, b) -> c
- curry :: ((a, b) -> c) -> a -> b -> c
- subtract :: Num a => a -> a -> a
- asTypeOf :: a -> a -> a
- until :: (a -> Bool) -> (a -> a) -> a -> a
- ($!) :: (a -> b) -> a -> b
- flip :: (a -> b -> c) -> b -> a -> c
- const :: a -> b -> a
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- (<|>) :: Alternative f => f a -> f a -> f a
- type String = [Char]
- error :: HasCallStack => [Char] -> a
- data SomeException
- (&&) :: Bool -> Bool -> Bool
- (||) :: Bool -> Bool -> Bool
- not :: Bool -> Bool
- terror :: HasCallStack => Text -> a
- getArgs :: MonadIO m => m [Text]
- equating :: Eq a => (b -> a) -> b -> b -> Bool
- type LText = Text
- type LByteString = ByteString
- type UVector = Vector
- type SVector = Vector
- data Vector a
- class (Vector Vector a, MVector MVector a) => Unbox a
- data HashMap k v
- data HashSet a
- data Text
- class Hashable a where
- (<.>) :: FilePath -> String -> FilePath
- (</>) :: FilePath -> FilePath -> FilePath
- data Set a
- data Seq a
- data Map k a
- data IntSet
- data IntMap a
- data ByteString
- lift :: (MonadTrans t, Monad m) => m a -> t m a
- undefined :: HasCallStack => a
- (++) :: Monoid m => m -> m -> m
- class Semigroup a where
- data WrappedMonoid m
- module Data.Functor
- liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
- optional :: Alternative f => f a -> f (Maybe a)
- liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- liftA :: Applicative f => (a -> b) -> f a -> f b
- (<**>) :: Applicative f => f a -> f (a -> b) -> f b
- class Applicative f => Alternative (f :: * -> *) where
- (<&&>) :: Applicative a => a Bool -> a Bool -> a Bool
- (<||>) :: Applicative a => a Bool -> a Bool -> a Bool
- guard :: Alternative f => Bool -> f ()
- join :: Monad m => m (m a) -> m a
- liftM :: Monad m => (a1 -> r) -> m a1 -> m r
- unless :: Applicative f => Bool -> f () -> f ()
- replicateM_ :: Applicative m => Int -> m a -> m ()
- forever :: Applicative f => f a -> f b
- (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- void :: Functor f => f a -> f ()
- ap :: Monad m => m (a -> b) -> m a -> m b
- liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r
- liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
- liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
- liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
- when :: Applicative f => Bool -> f () -> f ()
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- class (Alternative m, Monad m) => MonadPlus (m :: * -> *) where
- whenM :: Monad m => m Bool -> m () -> m ()
- unlessM :: Monad m => m Bool -> m () -> m ()
- module UnliftIO
- orElseSTM :: STM a -> STM a -> STM a
- 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 :: (PrimBase m1, PrimMonad m2, PrimState m1 ~ PrimState m2) => m1 a -> m2 a
- primToIO :: (PrimBase m, PrimState m ~ RealWorld) => m a -> IO a
- primToST :: PrimBase m => m a -> ST (PrimState m) a
- module Data.Primitive.MutVar
- trace :: String -> a -> a
- traceShow :: Show a => a -> b -> b
- traceId :: String -> String
- traceM :: Monad m => String -> m ()
- traceShowId :: Show a => a -> a
- traceShowM :: (Show a, Monad m) => a -> m ()
- formatTime :: FormatTime t => TimeLocale -> String -> t -> String
- parseTime :: ParseTime t => TimeLocale -> String -> String -> Maybe t
- parseTimeM :: (Monad m, ParseTime t) => Bool -> TimeLocale -> String -> String -> m t
- defaultTimeLocale :: TimeLocale
- getCurrentTime :: IO UTCTime
- data UTCTime = UTCTime {
- utctDay :: Day
- utctDayTime :: DiffTime
- fromGregorian :: Integer -> Int -> Int -> Day
- toGregorian :: Day -> (Integer, Int, Int)
- newtype Day = ModifiedJulianDay {}
- class Generic a
- newtype Identity a = Identity {
- runIdentity :: a
- class Monad m => MonadReader r (m :: * -> *) | m -> r
- ask :: MonadReader r m => m r
- asks :: MonadReader r m => (r -> a) -> m a
- newtype ReaderT r (m :: k -> *) (a :: k) :: forall k. * -> (k -> *) -> k -> * = ReaderT {
- runReaderT :: r -> m a
- type Reader r = ReaderT r Identity
- class Foldable (t :: * -> *)
- class (Functor t, Foldable t) => Traversable (t :: * -> *) where
- forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)
- for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)
- module Data.Bifunctor
- module Data.MonoTraversable
- module Data.MonoTraversable.Unprefixed
- module Data.Sequences
- module Data.Containers
- module Data.Builder
- module Data.NonNull
- toByteVector :: ByteString -> SVector Word8
- fromByteVector :: SVector Word8 -> ByteString
- module Say
- yieldThread :: MonadIO m => m ()
- waitAsync :: MonadIO m => Async a -> m a
- pollAsync :: MonadIO m => Async a -> m (Maybe (Either SomeException a))
- waitCatchAsync :: MonadIO m => Async a -> m (Either SomeException a)
- linkAsync :: MonadIO m => Async a -> m ()
- link2Async :: MonadIO m => Async a -> Async b -> m ()
- map :: Functor f => (a -> b) -> f a -> f b
- readMay :: (Element c ~ Char, MonoFoldable c, Read a) => c -> Maybe a
- zip :: Zip f => f a -> f b -> f (a, b)
- zip3 :: Zip3 f => f a -> f b -> f c -> f (a, b, c)
- zip4 :: Zip4 f => f a -> f b -> f c -> f d -> f (a, b, c, d)
- zip5 :: Zip5 f => f a -> f b -> f c -> f d -> f e -> f (a, b, c, d, e)
- zip6 :: Zip6 f => f a -> f b -> f c -> f d -> f e -> f g -> f (a, b, c, d, e, g)
- zip7 :: Zip7 f => f a -> f b -> f c -> f d -> f e -> f g -> f h -> f (a, b, c, d, e, g, h)
- unzip :: Zip f => f (a, b) -> (f a, f b)
- unzip3 :: Zip3 f => f (a, b, c) -> (f a, f b, f c)
- unzip4 :: Zip4 f => f (a, b, c, d) -> (f a, f b, f c, f d)
- unzip5 :: Zip5 f => f (a, b, c, d, e) -> (f a, f b, f c, f d, f e)
- unzip6 :: Zip6 f => f (a, b, c, d, e, g) -> (f a, f b, f c, f d, f e, f g)
- unzip7 :: Zip7 f => f (a, b, c, d, e, g, h) -> (f a, f b, f c, f d, f e, f g, f h)
- zipWith :: Zip f => (a -> b -> c) -> f a -> f b -> f c
- zipWith3 :: Zip3 f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- zipWith4 :: Zip4 f => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e
- zipWith5 :: Zip5 f => (a -> b -> c -> d -> e -> g) -> f a -> f b -> f c -> f d -> f e -> f g
- zipWith6 :: Zip6 f => (a -> b -> c -> d -> e -> g -> h) -> f a -> f b -> f c -> f d -> f e -> f g -> f h
- zipWith7 :: Zip7 f => (a -> b -> c -> d -> e -> g -> h -> i) -> f a -> f b -> f c -> f d -> f e -> f g -> f h -> f i
- hashNub :: (Hashable a, Eq a) => [a] -> [a]
- ordNub :: Ord a => [a] -> [a]
- ordNubBy :: Ord b => (a -> b) -> (a -> a -> Bool) -> [a] -> [a]
- sortWith :: (Ord a, IsSequence c) => (Element c -> a) -> c -> c
- repeat :: a -> [a]
- (\\) :: SetContainer a => a -> a -> a
- intersect :: SetContainer a => a -> a -> a
- class Show a where
- tshow :: Show a => a -> Text
- tlshow :: Show a => a -> LText
- charToLower :: Char -> Char
- charToUpper :: Char -> Char
- readFile :: MonadIO m => FilePath -> m ByteString
- readFileUtf8 :: MonadIO m => FilePath -> m Text
- writeFile :: MonadIO m => FilePath -> ByteString -> m ()
- writeFileUtf8 :: MonadIO m => FilePath -> Text -> m ()
- hGetContents :: MonadIO m => Handle -> m ByteString
- hPut :: MonadIO m => Handle -> ByteString -> m ()
- hGetChunk :: MonadIO m => Handle -> m ByteString
- print :: (Show a, MonadIO m) => a -> m ()
- putChar :: MonadIO m => Char -> m ()
- putStr :: MonadIO m => Text -> m ()
- putStrLn :: MonadIO m => Text -> m ()
- getChar :: MonadIO m => m Char
- getLine :: MonadIO m => m Text
- getContents :: MonadIO m => m LText
- interact :: MonadIO m => (LText -> LText) -> m ()
- data DList a
- asDList :: DList a -> DList a
- applyDList :: DList a -> [a] -> [a]
- force :: NFData a => a -> a
- ($!!) :: NFData a => (a -> b) -> a -> b
- deepseq :: NFData a => a -> b -> b
- class NFData a where
- 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
- asIntMap :: IntMap v -> IntMap v
- asMaybe :: Maybe a -> Maybe a
- asSet :: Set a -> Set a
- asIntSet :: IntSet -> IntSet
- asVector :: Vector a -> Vector a
- asUVector :: UVector a -> UVector a
- asSVector :: SVector a -> SVector a
- asString :: [Char] -> [Char]
CorePrelude
The value of seq a b
is bottom if a
is bottom, and
otherwise equal to b
. In other words, it evaluates the first
argument a
to weak head normal form (WHNF). seq
is usually
introduced to improve performance by avoiding unneeded laziness.
A note on evaluation order: the expression seq a b
does
not guarantee that a
will be evaluated before b
.
The only guarantee given by seq
is that the both a
and b
will be evaluated before seq
returns a value.
In particular, this means that b
may be evaluated before
a
. If you need to guarantee a specific order of evaluation,
you must use the function pseq
from the "parallel" package.
($) :: (a -> b) -> a -> b infixr 0 #
Application operator. This operator is redundant, since ordinary
application (f x)
means the same as (f
. However, $
x)$
has
low, right-associative binding precedence, so it sometimes allows
parentheses to be omitted; for example:
f $ g $ h x = f (g (h x))
It is also useful in higher-order situations, such as
,
or map
($
0) xs
.zipWith
($
) fs xs
fromIntegral :: (Integral a, Num b) => a -> b #
general coercion from integral types
realToFrac :: (Real a, Fractional b) => a -> b #
general coercion to fractional types
The Bounded
class is used to name the upper and lower limits of a
type. Ord
is not a superclass of Bounded
since types that are not
totally ordered may also have upper and lower bounds.
The Bounded
class may be derived for any enumeration type;
minBound
is the first constructor listed in the data
declaration
and maxBound
is the last.
Bounded
may also be derived for single-constructor datatypes whose
constituent types are in Bounded
.
Instances
Class Enum
defines operations on sequentially ordered types.
The enumFrom
... methods are used in Haskell's translation of
arithmetic sequences.
Instances of Enum
may be derived for any enumeration type (types
whose constructors have no fields). The nullary constructors are
assumed to be numbered left-to-right by fromEnum
from 0
through n-1
.
See Chapter 10 of the Haskell Report for more details.
For any type that is an instance of class Bounded
as well as Enum
,
the following should hold:
- The calls
andsucc
maxBound
should result in a runtime error.pred
minBound
fromEnum
andtoEnum
should give a runtime error if the result value is not representable in the result type. For example,
is an error.toEnum
7 ::Bool
enumFrom
andenumFromThen
should be defined with an implicit bound, thus:
enumFrom x = enumFromTo x maxBound enumFromThen x y = enumFromThenTo x y bound where bound | fromEnum y >= fromEnum x = maxBound | otherwise = minBound
Methods
the successor of a value. For numeric types, succ
adds 1.
the predecessor of a value. For numeric types, pred
subtracts 1.
Convert from an Int
.
Convert to an Int
.
It is implementation-dependent what fromEnum
returns when
applied to a value that is too large to fit in an Int
.
Used in Haskell's translation of [n..]
.
enumFromThen :: a -> a -> [a] #
Used in Haskell's translation of [n,n'..]
.
enumFromTo :: a -> a -> [a] #
Used in Haskell's translation of [n..m]
.
enumFromThenTo :: a -> a -> a -> [a] #
Used in Haskell's translation of [n,n'..m]
.
Instances
The Eq
class defines equality (==
) and inequality (/=
).
All the basic datatypes exported by the Prelude are instances of Eq
,
and Eq
may be derived for any datatype whose constituents are also
instances of Eq
.
Instances
class Fractional a => Floating a where #
Trigonometric and hyperbolic functions and related functions.
Minimal complete definition
pi, exp, log, sin, cos, asin, acos, atan, sinh, cosh, asinh, acosh, atanh
Instances
class Num a => Fractional a where #
Fractional numbers, supporting real division.
Minimal complete definition
fromRational, (recip | (/))
Methods
fractional division
reciprocal fraction
fromRational :: Rational -> a #
Conversion from a Rational
(that is
).
A floating literal stands for an application of Ratio
Integer
fromRational
to a value of type Rational
, so such literals have type
(
.Fractional
a) => a
Instances
Fractional CFloat | |
Fractional CDouble | |
Fractional DiffTime | |
Integral a => Fractional (Ratio a) | Since: base-2.0.1 |
RealFloat a => Fractional (Complex a) | Since: base-2.1 |
HasResolution a => Fractional (Fixed a) | Since: base-2.1 |
Fractional a => Fractional (Identity a) | |
Fractional a => Fractional (Const a b) | |
Fractional a => Fractional (Tagged s a) | |
class (Real a, Enum a) => Integral a where #
Integral numbers, supporting integer division.
Methods
quot :: a -> a -> a infixl 7 #
integer division truncated toward zero
integer remainder, satisfying
(x `quot` y)*y + (x `rem` y) == x
integer division truncated toward negative infinity
integer modulus, satisfying
(x `div` y)*y + (x `mod` y) == x
conversion to Integer
Instances
class Applicative m => Monad (m :: * -> *) where #
The Monad
class defines the basic operations over a monad,
a concept from a branch of mathematics known as category theory.
From the perspective of a Haskell programmer, however, it is best to
think of a monad as an abstract datatype of actions.
Haskell's do
expressions provide a convenient syntax for writing
monadic expressions.
Instances of Monad
should satisfy the following laws:
Furthermore, the Monad
and Applicative
operations should relate as follows:
The above laws imply:
and that pure
and (<*>
) satisfy the applicative functor laws.
The instances of Monad
for lists, Maybe
and IO
defined in the Prelude satisfy these laws.
Minimal complete definition
Methods
(>>=) :: m a -> (a -> m b) -> m b infixl 1 #
Sequentially compose two actions, passing any value produced by the first as an argument to the second.
(>>) :: m a -> m b -> m b infixl 1 #
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
Inject a value into the monadic type.
Fail with a message. This operation is not part of the
mathematical definition of a monad, but is invoked on pattern-match
failure in a do
expression.
As part of the MonadFail proposal (MFP), this function is moved
to its own class MonadFail
(see Control.Monad.Fail for more
details). The definition here will be removed in a future
release.
Instances
Monad [] | Since: base-2.1 |
Monad Maybe | Since: base-2.1 |
Monad IO | Since: base-2.1 |
Monad Par1 | Since: base-4.9.0.0 |
Monad Q | |
Monad Complex | Since: base-4.9.0.0 |
Monad Min | Since: base-4.9.0.0 |
Monad Max | Since: base-4.9.0.0 |
Monad First | Since: base-4.9.0.0 |
Monad Last | Since: base-4.9.0.0 |
Monad Option | Since: base-4.9.0.0 |
Monad Identity | Since: base-4.8.0.0 |
Monad STM | Since: base-4.3.0.0 |
Monad Down | Since: base-4.11.0.0 |
Monad ReadP | Since: base-2.1 |
Monad NonEmpty | Since: base-4.9.0.0 |
Monad Vector | |