| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Data.GI.Base.ShortPrelude
Description
The Haskell Prelude exports a number of symbols that can easily collide with functions appearing in bindings. The generated code requires just a small subset of the functions in the Prelude, together with some of the functionality in Data.GI.Base, we reexport this explicitly here.
Synopsis
- data Char
- chr :: Int -> Char
- ord :: Char -> Int
- data Int
- data Int8
- data Int16
- data Int32
- data Int64
- data Word8
- data Word16
- data Word32
- data Word64
- data ByteString
- type CString = Ptr CChar
- newtype CInt = CInt Int32
- newtype CUInt = CUInt Word32
- newtype CLong = CLong Int64
- newtype CULong = CULong Word64
- newtype CFloat = CFloat Float
- newtype CDouble = CDouble Double
- newtype CIntPtr = CIntPtr Int64
- newtype CUIntPtr = CUIntPtr Word64
- data Ptr a
- data FunPtr a
- castPtrToFunPtr :: Ptr a -> FunPtr b
- castFunPtrToPtr :: FunPtr a -> Ptr b
- plusPtr :: Ptr a -> Int -> Ptr b
- nullPtr :: Ptr a
- data ForeignPtr a
- unsafeForeignPtrToPtr :: ForeignPtr a -> Ptr a
- sizeOf :: Storable a => a -> Int
- peek :: Storable a => Ptr a -> IO a
- poke :: Storable a => Ptr a -> a -> IO ()
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- onException :: IO a -> IO b -> IO a
- class Monad m => MonadIO (m :: Type -> Type) where
- type AttrClearC info obj attr = (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed AttrClear info obj)
- type AttrGetC info obj attr result = (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed AttrGet info obj, result ~ AttrGetType info)
- data AttrOp obj (tag :: AttrOpTag) where
- (:=) :: (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed tag info obj, AttrSetTypeConstraint info b) => AttrLabelProxy (attr :: Symbol) -> b -> AttrOp obj tag
- (:=>) :: (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed tag info obj, AttrSetTypeConstraint info b) => AttrLabelProxy (attr :: Symbol) -> IO b -> AttrOp obj tag
- (:~) :: (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, tag ~ AttrSet, AttrOpAllowed AttrSet info obj, AttrOpAllowed AttrGet info obj, AttrSetTypeConstraint info b, a ~ AttrGetType info) => AttrLabelProxy (attr :: Symbol) -> (a -> b) -> AttrOp obj tag
- (:~>) :: (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, tag ~ AttrSet, AttrOpAllowed AttrSet info obj, AttrOpAllowed AttrGet info obj, AttrSetTypeConstraint info b, a ~ AttrGetType info) => AttrLabelProxy (attr :: Symbol) -> (a -> IO b) -> AttrOp obj tag
- type AttrConstructC info obj attr value = (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed AttrConstruct info obj, AttrSetTypeConstraint info value)
- type AttrSetC info obj attr value = (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed AttrSet info obj, AttrSetTypeConstraint info value)
- data AttrOpTag
- type family AttrOpAllowed (tag :: AttrOpTag) (info :: *) (useType :: *) :: Constraint where ...
- class AttrInfo (info :: *) where
- type AttrAllowedOps info :: [AttrOpTag]
- type AttrSetTypeConstraint info :: * -> Constraint
- type AttrBaseTypeConstraint info :: * -> Constraint
- type AttrGetType info
- type AttrLabel info :: Symbol
- type AttrOrigin info
- attrGet :: AttrBaseTypeConstraint info o => Proxy info -> o -> IO (AttrGetType info)
- attrSet :: (AttrBaseTypeConstraint info o, AttrSetTypeConstraint info b) => Proxy info -> o -> b -> IO ()
- attrClear :: AttrBaseTypeConstraint info o => Proxy info -> o -> IO ()
- attrConstruct :: (AttrBaseTypeConstraint info o, AttrSetTypeConstraint info b) => Proxy info -> b -> IO (GValueConstruct o)
- data AttrLabelProxy (a :: Symbol) = AttrLabelProxy
- clear :: forall info attr obj m. (AttrClearC info obj attr, MonadIO m) => obj -> AttrLabelProxy (attr :: Symbol) -> m ()
- module Data.GI.Base.BasicTypes
- module Data.GI.Base.BasicConversions
- module Data.GI.Base.Closure
- module Data.GI.Base.Constructible
- module Data.GI.Base.GError
- module Data.GI.Base.GHashTable
- module Data.GI.Base.GParamSpec
- module Data.GI.Base.GObject
- module Data.GI.Base.GVariant
- module Data.GI.Base.GValue
- module Data.GI.Base.ManagedPtr
- module Data.GI.Base.Properties
- data GObjectNotifySignalInfo (propName :: Symbol)
- data SignalConnectMode
- class SignalInfo (info :: *) where
- type HaskellCallbackType info
- connectSignal :: GObject o => SignalProxy o info -> o -> HaskellCallbackType info -> SignalConnectMode -> IO SignalHandlerId
- type SignalHandlerId = CULong
- connectSignalFunPtr :: GObject o => o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
- module Data.GI.Base.Utils
- data Symbol
- class Enum a where
- class Show a where
- class Eq a where
- data IO a
- class Applicative m => Monad (m :: Type -> Type) where
- data Maybe a
- (.) :: (b -> c) -> (a -> b) -> a -> c
- ($) :: (a -> b) -> a -> b
- (++) :: [a] -> [a] -> [a]
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- data Bool
- data Float
- data Double
- undefined :: HasCallStack => a
- error :: HasCallStack => [Char] -> a
- map :: (a -> b) -> [a] -> [b]
- length :: Foldable t => t a -> Int
- mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
- mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
- when :: Applicative f => Bool -> f () -> f ()
- fromIntegral :: (Integral a, Num b) => a -> b
- realToFrac :: (Real a, Fractional b) => a -> b
Documentation
The character type Char is an enumeration whose values represent
Unicode (or equivalently ISO/IEC 10646) code points (i.e. characters, see
http://www.unicode.org/ for details). This set extends the ISO 8859-1
(Latin-1) character set (the first 256 characters), which is itself an extension
of the ASCII character set (the first 128 characters). A character literal in
Haskell has type Char.
To convert a Char to or from the corresponding Int value defined
by Unicode, use toEnum and fromEnum from the
Enum class respectively (or equivalently ord and chr).
Instances
A fixed-precision integer type with at least the range [-2^29 .. 2^29-1].
The exact range for a given implementation can be determined by using
minBound and maxBound from the Bounded class.
Instances
8-bit signed integer type
Instances
16-bit signed integer type
Instances
32-bit signed integer type
Instances
64-bit signed integer type
Instances
8-bit unsigned integer type
Instances
16-bit unsigned integer type
Instances
32-bit unsigned integer type
Instances
64-bit unsigned integer type
Instances
data ByteString Source #
A space-efficient representation of a Word8 vector, supporting many
efficient operations.
A ByteString contains 8-bit bytes, or by using the operations from
Data.ByteString.Char8 it can be interpreted as containing 8-bit
characters.
Instances
type CString = Ptr CChar Source #
A C string is a reference to an array of C characters terminated by NUL.
Haskell type representing the C int type.
Instances
Haskell type representing the C unsigned int type.
Instances
Haskell type representing the C long type.
Instances
Haskell type representing the C unsigned long type.
Instances
Haskell type representing the C float type.
Instances
Haskell type representing the C double type.
Instances
Instances
Instances
A value of type represents a pointer to an object, or an
array of objects, which may be marshalled to or from Haskell values
of type Ptr aa.
The type a will often be an instance of class
Storable which provides the marshalling operations.
However this is not essential, and you can provide your own operations
to access the pointer. For example you might write small foreign
functions to get or set the fields of a C struct.
Instances
| Eq (Ptr a) | Since: base-2.1 |
| Ord (Ptr a) | Since: base-2.1 |
Defined in GHC.Ptr | |
| Show (Ptr a) | Since: base-2.1 |
| Storable (Ptr a) | Since: base-2.1 |
Defined in Foreign.Storable Methods sizeOf :: Ptr a -> Int Source # alignment :: Ptr a -> Int Source # peekElemOff :: Ptr (Ptr a) -> Int -> IO (Ptr a) Source # pokeElemOff :: Ptr (Ptr a) -> Int -> Ptr a -> IO () Source # peekByteOff :: Ptr b -> Int -> IO (Ptr a) Source # pokeByteOff :: Ptr b -> Int -> Ptr a -> IO () Source # | |
| IsGValue (Ptr a) Source # | |
| Foldable (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => URec (Ptr ()) m -> m Source # foldMap :: Monoid m => (a -> m) -> URec (Ptr ()) a -> m Source # foldr :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b Source # foldr' :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b Source # foldl :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b Source # foldl' :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b Source # foldr1 :: (a -> a -> a) -> URec (Ptr ()) a -> a Source # foldl1 :: (a -> a -> a) -> URec (Ptr ()) a -> a Source # toList :: URec (Ptr ()) a -> [a] Source # null :: URec (Ptr ()) a -> Bool Source # length :: URec (Ptr ()) a -> Int Source # elem :: Eq a => a -> URec (Ptr ()) a -> Bool Source # maximum :: Ord a => URec (Ptr ()) a -> a Source # minimum :: Ord a => URec (Ptr ()) a -> a Source # | |
| Traversable (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> URec (Ptr ()) a -> f (URec (Ptr ()) b) Source # sequenceA :: Applicative f => URec (Ptr ()) (f a) -> f (URec (Ptr ()) a) Source # mapM :: Monad m => (a -> m b) -> URec (Ptr ()) a -> m (URec (Ptr ()) b) Source # sequence :: Monad m => URec (Ptr ()) (m a) -> m (URec (Ptr ()) a) Source # | |
A value of type is a pointer to a function callable
from foreign code. The type FunPtr aa will normally be a foreign type,
a function type with zero or more arguments where
- the argument types are marshallable foreign types,
i.e.
Char,Int,Double,Float,Bool,Int8,Int16,Int32,Int64,Word8,Word16,Word32,Word64,,Ptra,FunPtraor a renaming of any of these usingStablePtranewtype. - the return type is either a marshallable foreign type or has the form
whereIOttis a marshallable foreign type or().
A value of type may be a pointer to a foreign function,
either returned by another foreign function or imported with a
a static address import likeFunPtr a
foreign import ccall "stdlib.h &free" p_free :: FunPtr (Ptr a -> IO ())
or a pointer to a Haskell function created using a wrapper stub
declared to produce a FunPtr of the correct type. For example:
type Compare = Int -> Int -> Bool foreign import ccall "wrapper" mkCompare :: Compare -> IO (FunPtr Compare)
Calls to wrapper stubs like mkCompare allocate storage, which
should be released with freeHaskellFunPtr when no
longer required.
To convert FunPtr values to corresponding Haskell functions, one
can define a dynamic stub for the specific foreign type, e.g.
type IntFunction = CInt -> IO () foreign import ccall "dynamic" mkFun :: FunPtr IntFunction -> IntFunction
Instances
| Eq (FunPtr a) | |
| Ord (FunPtr a) | |
Defined in GHC.Ptr | |
| Show (FunPtr a) | Since: base-2.1 |
| Storable (FunPtr a) | Since: base-2.1 |
Defined in Foreign.Storable Methods sizeOf :: FunPtr a -> Int Source # alignment :: FunPtr a -> Int Source # peekElemOff :: Ptr (FunPtr a) -> Int -> IO (FunPtr a) Source # pokeElemOff :: Ptr (FunPtr a) -> Int -> FunPtr a -> IO () Source # peekByteOff :: Ptr b -> Int -> IO (FunPtr a) Source # pokeByteOff :: Ptr b -> Int -> FunPtr a -> IO () Source # | |
castPtrToFunPtr :: Ptr a -> FunPtr b Source #
castFunPtrToPtr :: FunPtr a -> Ptr b Source #
data ForeignPtr a Source #
The type ForeignPtr represents references to objects that are
maintained in a foreign language, i.e., that are not part of the
data structures usually managed by the Haskell storage manager.
The essential difference between ForeignPtrs and vanilla memory
references of type Ptr a is that the former may be associated
with finalizers. A finalizer is a routine that is invoked when
the Haskell storage manager detects that - within the Haskell heap
and stack - there are no more references left that are pointing to
the ForeignPtr. Typically, the finalizer will, then, invoke
routines in the foreign language that free the resources bound by
the foreign object.
The ForeignPtr is parameterised in the same way as Ptr. The
type argument of ForeignPtr should normally be an instance of
class Storable.
Instances
| Eq (ForeignPtr a) | Since: base-2.1 |
Defined in GHC.ForeignPtr Methods (==) :: ForeignPtr a -> ForeignPtr a -> Bool Source # (/=) :: ForeignPtr a -> ForeignPtr a -> Bool Source # | |
| Ord (ForeignPtr a) | Since: base-2.1 |
Defined in GHC.ForeignPtr Methods compare :: ForeignPtr a -> ForeignPtr a -> Ordering Source # (<) :: ForeignPtr a -> ForeignPtr a -> Bool Source # (<=) :: ForeignPtr a -> ForeignPtr a -> Bool Source # (>) :: ForeignPtr a -> ForeignPtr a -> Bool Source # (>=) :: ForeignPtr a -> ForeignPtr a -> Bool Source # max :: ForeignPtr a -> ForeignPtr a -> ForeignPtr a Source # min :: ForeignPtr a -> ForeignPtr a -> ForeignPtr a Source # | |
| Show (ForeignPtr a) | Since: base-2.1 |
Defined in GHC.ForeignPtr | |
unsafeForeignPtrToPtr :: ForeignPtr a -> Ptr a Source #
This function extracts the pointer component of a foreign
pointer. This is a potentially dangerous operations, as if the
argument to unsafeForeignPtrToPtr is the last usage
occurrence of the given foreign pointer, then its finalizer(s) will
be run, which potentially invalidates the plain pointer just
obtained. Hence, touchForeignPtr must be used
wherever it has to be guaranteed that the pointer lives on - i.e.,
has another usage occurrence.
To avoid subtle coding errors, hand written marshalling code
should preferably use withForeignPtr rather
than combinations of unsafeForeignPtrToPtr and
touchForeignPtr. However, the latter routines
are occasionally preferred in tool generated marshalling code.
sizeOf :: Storable a => a -> Int Source #
Computes the storage requirements (in bytes) of the argument. The value of the argument is not used.
peek :: Storable a => Ptr a -> IO a Source #
Read a value from the given memory location.
Note that the peek and poke functions might require properly
aligned addresses to function correctly. This is architecture
dependent; thus, portable code should ensure that when peeking or
poking values of some type a, the alignment
constraint for a, as given by the function
alignment is fulfilled.
poke :: Storable a => Ptr a -> a -> IO () Source #
Write the given value to the given memory location. Alignment
restrictions might apply; see peek.
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 Source #
An infix synonym for fmap.
The name of this operator is an allusion to $.
Note the similarities between their types:
($) :: (a -> b) -> a -> b (<$>) :: Functor f => (a -> b) -> f a -> f b
Whereas $ is function application, <$> is function
application lifted over a Functor.
Examples
Convert from a to a Maybe Int using Maybe Stringshow:
>>>show <$> NothingNothing>>>show <$> Just 3Just "3"
Convert from an to an Either Int IntEither IntString using show:
>>>show <$> Left 17Left 17>>>show <$> Right 17Right "17"
Double each element of a list:
>>>(*2) <$> [1,2,3][2,4,6]
Apply even to the second element of a pair:
>>>even <$> (2,2)(2,True)
onException :: IO a -> IO b -> IO a Source #
Like finally, but only performs the final action if there was an
exception raised by the computation.
type AttrClearC info obj attr = (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed AttrClear info obj) Source #
Constraint on a obj/attr pair so that clear is allowed.
type AttrGetC info obj attr result = (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed AttrGet info obj, result ~ AttrGetType info) Source #
Constraints on a obj/attr pair so get is possible,
producing a value of type result.
data AttrOp obj (tag :: AttrOpTag) where Source #
Constructors for the different operations allowed on an attribute.
Constructors
| (:=) :: (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed tag info obj, AttrSetTypeConstraint info b) => AttrLabelProxy (attr :: Symbol) -> b -> AttrOp obj tag infixr 0 | Assign a value to an attribute |
| (:=>) :: (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed tag info obj, AttrSetTypeConstraint info b) => AttrLabelProxy (attr :: Symbol) -> IO b -> AttrOp obj tag infixr 0 | Assign the result of an IO action to an attribute |
| (:~) :: (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, tag ~ AttrSet, AttrOpAllowed AttrSet info obj, AttrOpAllowed AttrGet info obj, AttrSetTypeConstraint info b, a ~ AttrGetType info) => AttrLabelProxy (attr :: Symbol) -> (a -> b) -> AttrOp obj tag infixr 0 | Apply an update function to an attribute |
| (:~>) :: (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, tag ~ AttrSet, AttrOpAllowed AttrSet info obj, AttrOpAllowed AttrGet info obj, AttrSetTypeConstraint info b, a ~ AttrGetType info) => AttrLabelProxy (attr :: Symbol) -> (a -> IO b) -> AttrOp obj tag infixr 0 | Apply an IO update function to an attribute |
type AttrConstructC info obj attr value = (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed AttrConstruct info obj, AttrSetTypeConstraint info value) Source #
Constraint on a obj/value pair so that new works on values
of type @value.
type AttrSetC info obj attr value = (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed AttrSet info obj, AttrSetTypeConstraint info value) Source #
Constraint on a obj/attr pair so that set works on values
of type value.
Possible operations on an attribute.
Constructors
| AttrGet | |
| AttrSet | |
| AttrConstruct | |
| AttrClear |
Instances
| Bounded AttrOpTag Source # | |
| Enum AttrOpTag Source # | |
Defined in Data.GI.Base.Attributes Methods succ :: AttrOpTag -> AttrOpTag Source # pred :: AttrOpTag -> AttrOpTag Source # toEnum :: Int -> AttrOpTag Source # fromEnum :: AttrOpTag -> Int Source # enumFrom :: AttrOpTag -> [AttrOpTag] Source # enumFromThen :: AttrOpTag -> AttrOpTag -> [AttrOpTag] Source # enumFromTo :: AttrOpTag -> AttrOpTag -> [AttrOpTag] Source # enumFromThenTo :: AttrOpTag -> AttrOpTag -> AttrOpTag -> [AttrOpTag] Source # | |
| Eq AttrOpTag Source # | |
| Ord AttrOpTag Source # | |
Defined in Data.GI.Base.Attributes | |
| Show AttrOpTag Source # | |
type family AttrOpAllowed (tag :: AttrOpTag) (info :: *) (useType :: *) :: Constraint where ... Source #
Whether a given AttrOpTag is allowed on an attribute, given the
info type.
Equations
| AttrOpAllowed tag info useType = AttrOpIsAllowed tag (AttrAllowedOps info) (AttrLabel info) (AttrOrigin info) useType ~ OpIsAllowed |
class AttrInfo (info :: *) where Source #
Info describing an attribute.
Associated Types
type AttrAllowedOps info :: [AttrOpTag] Source #
The operations that are allowed on the attribute.
type AttrSetTypeConstraint info :: * -> Constraint Source #
Constraint on the value being set.
type AttrBaseTypeConstraint info :: * -> Constraint Source #
Constraint on the type for which we are allowed to create/set/get the attribute.
type AttrGetType info Source #
Type returned by attrGet.
type AttrLabel info :: Symbol Source #
Name of the attribute.
type AttrOrigin info Source #
Type which introduces the attribute.
Methods
attrGet :: AttrBaseTypeConstraint info o => Proxy info -> o -> IO (AttrGetType info) Source #
Get the value of the given attribute.
attrSet :: (AttrBaseTypeConstraint info o, AttrSetTypeConstraint info b) => Proxy info -> o -> b -> IO () Source #
Set the value of the given attribute, after the object having the attribute has already been created.
attrClear :: AttrBaseTypeConstraint info o => Proxy info -> o -> IO () Source #
Set the value of the given attribute to NULL (for nullable
attributes).
attrConstruct :: (AttrBaseTypeConstraint info o, AttrSetTypeConstraint info b) => Proxy info -> b -> IO (GValueConstruct o) Source #
Build a GValue representing the attribute.
data AttrLabelProxy (a :: Symbol) Source #
A proxy for attribute labels.
Constructors
| AttrLabelProxy |
Instances
| a ~ x => IsLabel x (AttrLabelProxy a) Source # | |
Defined in Data.GI.Base.Attributes Methods fromLabel :: AttrLabelProxy a Source # | |
| a ~ x => IsLabelProxy x (AttrLabelProxy a) Source # | Support for overloaded labels. |
Defined in Data.GI.Base.Attributes Methods fromLabelProxy :: Proxy x -> AttrLabelProxy a Source # | |
clear :: forall info attr obj m. (AttrClearC info obj attr, MonadIO m) => obj -> AttrLabelProxy (attr :: Symbol) -> m () Source #
Set a nullable attribute to NULL.
module Data.GI.Base.BasicTypes
module Data.GI.Base.Closure
module Data.GI.Base.Constructible
module Data.GI.Base.GError
module Data.GI.Base.GHashTable
module Data.GI.Base.GParamSpec
module Data.GI.Base.GObject
module Data.GI.Base.GVariant
module Data.GI.Base.GValue
module Data.GI.Base.ManagedPtr
module Data.GI.Base.Properties
data GObjectNotifySignalInfo (propName :: Symbol) Source #
Connection information for a "notify" signal indicating that a
specific property changed (see PropertyNotify for the relevant
constructor).
Instances
| KnownSymbol propName => SignalInfo (GObjectNotifySignalInfo propName) Source # | |
Defined in Data.GI.Base.Signals Associated Types type HaskellCallbackType (GObjectNotifySignalInfo propName) :: Type Source # Methods connectSignal :: GObject o => SignalProxy o (GObjectNotifySignalInfo propName) -> o -> HaskellCallbackType (GObjectNotifySignalInfo propName) -> SignalConnectMode -> IO SignalHandlerId Source # | |
| type HaskellCallbackType (GObjectNotifySignalInfo propName) Source # | |
Defined in Data.GI.Base.Signals | |
data SignalConnectMode Source #
Whether to connect a handler to a signal with connectSignal so
that it runs before/after the default handler for the given signal.
Constructors
| SignalConnectBefore | Run before the default handler. |
| SignalConnectAfter | Run after the default handler. |
class SignalInfo (info :: *) where Source #
Information about an overloaded signal.
Associated Types
type HaskellCallbackType info Source #
Methods
connectSignal :: GObject o => SignalProxy o info -> o -> HaskellCallbackType info -> SignalConnectMode -> IO SignalHandlerId Source #
Connect a Haskell function to a signal of the given GObject,
specifying whether the handler will be called before or after
the default handler.
Instances
| KnownSymbol propName => SignalInfo (GObjectNotifySignalInfo propName) Source # | |
Defined in Data.GI.Base.Signals Associated Types type HaskellCallbackType (GObjectNotifySignalInfo propName) :: Type Source # Methods connectSignal :: GObject o => SignalProxy o (GObjectNotifySignalInfo propName) -> o -> HaskellCallbackType (GObjectNotifySignalInfo propName) -> SignalConnectMode -> IO SignalHandlerId Source # | |
type SignalHandlerId = CULong Source #
Type of a GObject signal handler id.
connectSignalFunPtr :: GObject o => o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId Source #
Connect a signal to a handler, given as a FunPtr.
module Data.GI.Base.Utils
(Kind) This is the kind of type-level symbols. Declared here because class IP needs it
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
andsuccmaxBoundshould result in a runtime error.predminBound fromEnumandtoEnumshould give a runtime error if the result value is not representable in the result type. For example,is an error.toEnum7 ::BoolenumFromandenumFromThenshould 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 = minBoundMethods
Convert from an Int.
Instances
Conversion of values to readable Strings.
Derived instances of Show have the following properties, which
are compatible with derived instances of Read:
- The result of
showis a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used. - If the constructor is defined to be an infix operator, then
showsPrecwill produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
xis less thand(associativity is ignored). Thus, ifdis0then the result is never surrounded in parentheses; ifdis11it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
showwill produce the record-syntax form, with the fields given in the same order as the original declaration.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Show is equivalent to
instance (Show a) => Show (Tree a) where
showsPrec d (Leaf m) = showParen (d > app_prec) $
showString "Leaf " . showsPrec (app_prec+1) m
where app_prec = 10
showsPrec d (u :^: v) = showParen (d > up_prec) $
showsPrec (up_prec+1) u .
showString " :^: " .
showsPrec (up_prec+1) v
where up_prec = 5Note that right-associativity of :^: is ignored. For example,
produces the stringshow(Leaf 1 :^: Leaf 2 :^: Leaf 3)"Leaf 1 :^: (Leaf 2 :^: Leaf 3)".
Methods
Arguments
| :: Int | the operator precedence of the enclosing
context (a number from |
| -> a | the value to be converted to a |
| -> ShowS |
Convert a value to a readable String.
showsPrec should satisfy the law
showsPrec d x r ++ s == showsPrec d x (r ++ s)
Derived instances of Read and Show satisfy the following:
That is, readsPrec parses the string produced by
showsPrec, and delivers the value that showsPrec started with.
Instances
| Show Bool | Since: base-2.1 |
| Show Char | Since: base-2.1 |
| Show Int | Since: base-2.1 |
| Show Int8 | Since: base-2.1 |
| Show Int16 | Since: base-2.1 |
| Show Int32 | Since: base-2.1 |
| Show Int64 | Since: base-2.1 |
| Show Integer | Since: base-2.1 |
| Show Natural | Since: base-4.8.0.0 |
| Show Ordering | Since: base-2.1 |
| Show Word | Since: base-2.1 |
| Show Word8 | Since: base-2.1 |
| Show Word16 | Since: base-2.1 |
| Show Word32 | Since: base-2.1 |
| Show Word64 | Since: base-2.1 |
| Show RuntimeRep | Since: base-4.11.0.0 |
| Show VecCount | Since: base-4.11.0.0 |
| Show VecElem | Since: base-4.11.0.0 |
| Show CallStack | Since: base-4.9.0.0 |
| Show SomeTypeRep | Since: base-4.10.0.0 |
Defined in Data.Typeable.Internal | |
| Show () | Since: base-2.1 |
| Show TyCon | Since: base-2.1 |
| Show Module | Since: base-4.9.0.0 |
| Show TrName | Since: base-4.9.0.0 |
| Show KindRep | |
| Show TypeLitSort | Since: base-4.11.0.0 |
| Show Handle | Since: base-4.1.0.0 |
| Show HandleType | Since: base-4.1.0.0 |
| Show PatternMatchFail | Since: base-4.0 |
Defined in Control.Exception.Base | |
| Show RecSelError | Since: base-4.0 |
Defined in Control.Exception.Base | |
| Show RecConError | Since: base-4.0 |
Defined in Control.Exception.Base | |
| Show RecUpdError | Since: base-4.0 |
Defined in Control.Exception.Base | |
| Show NoMethodError | Since: base-4.0 |
Defined in Control.Exception.Base | |
| Show TypeError | Since: base-4.9.0.0 |
| Show NonTermination | Since: base-4.0 |
Defined in Control.Exception.Base | |
| Show NestedAtomically | Since: base-4.0 |
Defined in Control.Exception.Base | |
| Show BlockedIndefinitelyOnMVar | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception | |
| Show BlockedIndefinitelyOnSTM | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception | |
| Show Deadlock | Since: base-4.1.0.0 |
| Show AllocationLimitExceeded | Since: base-4.7.1.0 |
Defined in GHC.IO.Exception | |
| Show CompactionFailed | Since: base-4.10.0.0 |
Defined in GHC.IO.Exception | |
| Show AssertionFailed | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception | |
| Show SomeAsyncException | Since: base-4.7.0.0 |
Defined in GHC.IO.Exception | |
| Show AsyncException | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception | |
| Show ArrayException | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception | |
| Show FixIOException | Since: base-4.11.0.0 |
Defined in GHC.IO.Exception | |
| Show ExitCode | |
| Show IOErrorType | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception | |
| Show BufferMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types | |
| Show Newline | Since: base-4.3.0.0 |
| Show NewlineMode | Since: base-4.3.0.0 |
Defined in GHC.IO.Handle.Types | |
| Show MaskingState | Since: base-4.3.0.0 |
| Show IOException | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception | |
| Show ErrorCall | Since: base-4.0.0.0 |
| Show ArithException | Since: base-4.0.0.0 |
Defined in GHC.Exception.Type | |
| Show SomeSymbol | Since: base-4.7.0.0 |
Defined in GHC.TypeLits | |
| Show SomeNat | Since: base-4.7.0.0 |
| Show CChar | |
| Show CSChar | |
| Show CUChar | |
| Show CShort | |
| Show CUShort | |
| Show CInt | |
| Show CUInt | |
| Show CLong | |
| Show CULong | |
| Show CLLong | |
| Show CULLong | |
| Show CBool | |
| Show CFloat | |
| Show CDouble | |
| Show CPtrdiff | |
| Show CSize | |
| Show CWchar | |
| Show CSigAtomic | |
Defined in Foreign.C.Types | |
| Show CClock | |
| Show CTime | |
| Show CUSeconds | |
| Show CSUSeconds | |
Defined in Foreign.C.Types | |
| Show CIntPtr | |
| Show CUIntPtr | |
| Show CIntMax | |
| Show CUIntMax | |
| Show WordPtr | |
| Show IntPtr | |
| Show SrcLoc | Since: base-4.9.0.0 |
| Show SomeException | Since: base-3.0 |
Defined in GHC.Exception.Type | |
| Show ByteString | |
Defined in Data.ByteString.Internal | |
| Show I16 | |
| Show UnexpectedNullPointerReturn Source # | |
Defined in Data.GI.Base.BasicTypes | |
| Show GVariantSignature Source # | |
Defined in Data.GI.Base.GVariant | |
| Show GVariantObjectPath Source # | |
Defined in Data.GI.Base.GVariant | |
| Show GVariantHandle Source # | |
Defined in Data.GI.Base.GVariant | |
| Show AttrOpTag Source # | |
| Show GError Source # | |
| Show a => Show [a] | Since: base-2.1 |
| Show a => Show (Maybe a) | Since: base-2.1 |
| Show a => Show (Ratio a) | Since: base-2.0.1 |
| Show (Ptr a) | Since: base-2.1 |
| Show (FunPtr a) | Since: base-2.1 |
| Show (ForeignPtr a) | Since: base-2.1 |
Defined in GHC.ForeignPtr | |
| Show a => Show (ZipList a) | Since: base-4.7.0.0 |
| Show a => Show (First a) | Since: base-2.1 |
| Show a => Show (Last a) | Since: base-2.1 |
| Show a => Show (NonEmpty a) | Since: base-4.11.0.0 |
| Show a => Show (GVariantSinglet a) Source # | |
Defined in Data.GI.Base.GVariant | |
| (Show a, Show b) => Show (Either a b) | Since: base-3.0 |
| Show (TypeRep a) | |
| (Show a, Show b) => Show (a, b) | Since: base-2.1 |
| Show (Proxy s) | Since: base-4.7.0.0 |
| (Show k, Show a) => Show (Map k a) | |
| (Show key, Show value) => Show (GVariantDictEntry key value) Source # | |
Defined in Data.GI.Base.GVariant | |
| (Show a, Show b, Show c) => Show (a, b, c) | Since: base-2.1 |
| Show (f a) => Show (Ap f a) | Since: base-4.12.0.0 |
| Show (a :~: b) | Since: base-4.7.0.0 |
| (Show a, Show b, Show c, Show d) => Show (a, b, c, d) | Since: base-2.1 |
| Show (a :~~: b) | Since: base-4.10.0.0 |
| (Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e) | Since: base-2.1 |
| (Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f) | Since: base-2.1 |
| (Show a, Show b, Show c, Show d, Show e, Show f, Show g) => Show (a, b, c, d, e, f, g) | Since: base-2.1 |
| (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h) => Show (a, b, c, d, e, f, g, h) | Since: base-2.1 |
| (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i) => Show (a, b, c, d, e, f, g, h, i) | Since: base-2.1 |
| (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j) => Show (a, b, c, d, e, f, g, h, i, j) | Since: base-2.1 |
| (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k) => Show (a, b, c, d, e, f, g, h, i, j, k) | Since: base-2.1 |
| (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l) => Show (a, b, c, d, e, f, g, h, i, j, k, l) | Since: base-2.1 |
| (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m) | Since: base-2.1 |
| (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | Since: base-2.1 |
| (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n, Show o) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | Since: base-2.1 |
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.
The Haskell Report defines no laws for Eq. However, == is customarily
expected to implement an equivalence relationship where two values comparing
equal are indistinguishable by "public" functions, with a "public" function
being one not allowing to see implementation details. For example, for a
type representing non-normalised natural numbers modulo 100, a "public"
function doesn't make the difference between 1 and 201. It is expected to
have the following properties:
Instances
| Eq Bool | |
| Eq Char | |
| Eq Double | Note that due to the presence of
Also note that
|
| Eq Float | Note that due to the presence of
Also note that
|
| Eq Int | |
| Eq Int8 | Since: base-2.1 |
| Eq Int16 | Since: base-2.1 |
| Eq Int32 | Since: base-2.1 |
| Eq Int64 | Since: base-2.1 |
| Eq Integer | |
| Eq Natural | Since: base-4.8.0.0 |
| Eq Ordering | |
| Eq Word | |
| Eq Word8 | Since: base-2.1 |
| Eq Word16 | Since: base-2.1 |
| Eq Word32 | Since: base-2.1 |
| Eq Word64 | Since: base-2.1 |
| Eq SomeTypeRep | |
Defined in Data.Typeable.Internal Methods (==) :: SomeTypeRep -> SomeTypeRep -> Bool Source # (/=) :: SomeTypeRep -> SomeTypeRep -> Bool Source # | |
| Eq () | |
| Eq TyCon | |
| Eq Module | |
| Eq TrName | |
| Eq Handle | Since: base-4.1.0.0 |
| Eq BigNat | |
| Eq SpecConstrAnnotation | Since: base-4.3.0.0 |
Defined in GHC.Exts Methods (==) :: SpecConstrAnnotation -> SpecConstrAnnotation -> Bool Source # (/=) :: SpecConstrAnnotation -> SpecConstrAnnotation -> Bool Source # | |
| Eq Errno | Since: base-2.1 |
| Eq AsyncException | Since: base-4.2.0.0 |
Defined in GHC.IO.Exception Methods (==) :: AsyncException -> AsyncException -> Bool Source # (/=) :: AsyncException -> AsyncException -> Bool Source # | |
| Eq ArrayException | Since: base-4.2.0.0 |
Defined in GHC.IO.Exception Methods (==) :: ArrayException -> ArrayException -> Bool Source # (/=) :: ArrayException -> ArrayException -> Bool Source # | |
| Eq ExitCode | |
| Eq IOErrorType | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception Methods (==) :: IOErrorType -> IOErrorType -> Bool Source # (/=) :: IOErrorType -> IOErrorType -> Bool Source # | |
| Eq BufferMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types Methods (==) :: BufferMode -> BufferMode -> Bool Source # (/=) :: BufferMode -> BufferMode -> Bool Source # | |
| Eq Newline | Since: base-4.2.0.0 |
| Eq NewlineMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types Methods (==) :: NewlineMode -> NewlineMode -> Bool Source # (/=) :: NewlineMode -> NewlineMode -> Bool Source # | |
| Eq MaskingState | Since: base-4.3.0.0 |
Defined in GHC.IO Methods (==) :: MaskingState -> MaskingState -> Bool Source # (/=) :: MaskingState -> MaskingState -> Bool Source # | |
| Eq IOException | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception Methods (==) :: IOException -> IOException -> Bool Source # (/=) :: IOException -> IOException -> Bool Source # | |
| Eq ErrorCall | Since: base-4.7.0.0 |
| Eq ArithException | Since: base-3.0 |
Defined in GHC.Exception.Type Methods (==) :: ArithException -> ArithException -> Bool Source # (/=) :: ArithException -> ArithException -> Bool Source # | |
| Eq SomeSymbol | Since: base-4.7.0.0 |
Defined in GHC.TypeLits Methods (==) :: SomeSymbol -> SomeSymbol -> Bool Source # (/=) :: SomeSymbol -> SomeSymbol -> Bool Source # | |
| Eq SomeNat | Since: base-4.7.0.0 |
| Eq CChar | |
| Eq CSChar | |
| Eq CUChar | |
| Eq CShort | |
| Eq CUShort | |
| Eq CInt | |
| Eq CUInt | |
| Eq CLong | |
| Eq CULong | |
| Eq CLLong | |
| Eq CULLong | |
| Eq CBool | |
| Eq CFloat | |
| Eq CDouble | |
| Eq CPtrdiff | |
| Eq CSize | |
| Eq CWchar | |
| Eq CSigAtomic | |
Defined in Foreign.C.Types Methods (==) :: CSigAtomic -> CSigAtomic -> Bool Source # (/=) :: CSigAtomic -> CSigAtomic -> Bool Source # | |
| Eq CClock | |
| Eq CTime | |
| Eq CUSeconds | |
| Eq CSUSeconds | |
Defined in Foreign.C.Types Methods (==) :: CSUSeconds -> CSUSeconds -> Bool Source # (/=) :: CSUSeconds -> CSUSeconds -> Bool Source # | |
| Eq CIntPtr | |
| Eq CUIntPtr | |
| Eq CIntMax | |
| Eq CUIntMax | |
| Eq WordPtr | |
| Eq IntPtr | |
| Eq SrcLoc | Since: base-4.9.0.0 |
| Eq ByteString | |
Defined in Data.ByteString.Internal Methods (==) :: ByteString -> ByteString -> Bool Source # (/=) :: ByteString -> ByteString -> Bool Source # | |
| Eq I16 | |
| Eq GVariantSignature Source # | |
Defined in Data.GI.Base.GVariant Methods (==) :: GVariantSignature -> GVariantSignature -> Bool Source # (/=) :: GVariantSignature -> GVariantSignature -> Bool Source # | |
| Eq GVariantObjectPath Source # | |
Defined in Data.GI.Base.GVariant Methods (==) :: GVariantObjectPath -> GVariantObjectPath -> Bool Source # (/=) :: GVariantObjectPath -> GVariantObjectPath -> Bool Source # | |
| Eq GVariantHandle Source # | |
Defined in Data.GI.Base.GVariant Methods (==) :: GVariantHandle -> GVariantHandle -> Bool Source # (/=) :: GVariantHandle -> GVariantHandle -> Bool Source # | |
| Eq AttrOpTag Source # | |
| Eq a => Eq [a] | |
| Eq a => Eq (Maybe a) | Since: base-2.1 |
| Eq a => Eq (Ratio a) | Since: base-2.1 |
| Eq (StablePtr a) | Since: base-2.1 |
| Eq (Ptr a) | Since: base-2.1 |
| Eq (FunPtr a) | |
| Eq (ForeignPtr a) | Since: base-2.1 |
Defined in GHC.ForeignPtr Methods (==) :: ForeignPtr a -> ForeignPtr a -> Bool Source # (/=) :: ForeignPtr a -> ForeignPtr a -> Bool Source # | |
| Eq a => Eq (ZipList a) | Since: base-4.7.0.0 |
| Eq (IORef a) | ^ Pointer equality. Since: base-4.1.0.0 |
| Eq a => Eq (First a) | Since: base-2.1 |
| Eq a => Eq (Last a) | Since: base-2.1 |
| Eq a => Eq (NonEmpty a) | Since: base-4.9.0.0 |
| Eq a => Eq (GVariantSinglet a) Source # | |
Defined in Data.GI.Base.GVariant Methods (==) :: GVariantSinglet a -> GVariantSinglet a -> Bool Source # (/=) :: GVariantSinglet a -> GVariantSinglet a -> Bool Source # | |
| (Eq a, Eq b) => Eq (Either a b) | Since: base-2.1 |
| Eq (TypeRep a) | Since: base-2.1 |
| (Eq a, Eq b) => Eq (a, b) | |
| Eq (Proxy s) | Since: base-4.7.0.0 |
| (Eq k, Eq a) => Eq (Map k a) | |
| (Eq key, Eq value) => Eq (GVariantDictEntry key value) Source # | |
Defined in Data.GI.Base.GVariant Methods (==) :: GVariantDictEntry key value -> GVariantDictEntry key value -> Bool Source # (/=) :: GVariantDictEntry key value -> GVariantDictEntry key value -> Bool Source # | |
| (Eq a, Eq b, Eq c) => Eq (a, b, c) | |
| Eq (f a) => Eq (Ap f a) | Since: base-4.12.0.0 |
| Eq (a :~: b) | Since: base-4.7.0.0 |
| (Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d) | |
| Eq (a :~~: b) | Since: base-4.10.0.0 |
| (Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => Eq (a, b, c, d, e, f) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => Eq (a, b, c, d, e, f, g) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => Eq (a, b, c, d, e, f, g, h) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i) => Eq (a, b, c, d, e, f, g, h, i) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j) => Eq (a, b, c, d, e, f, g, h, i, j) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => Eq (a, b, c, d, e, f, g, h, i, j, k) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => Eq (a, b, c, d, e, f, g, h, i, j, k, l) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |
A value of type is a computation which, when performed,
does some I/O before returning a value of type IO aa.
There is really only one way to "perform" an I/O action: bind it to
Main.main in your program. When your program is run, the I/O will
be performed. It isn't possible to perform I/O from an arbitrary
function, unless that function is itself in the IO monad and called
at some point, directly or indirectly, from Main.main.
IO is a monad, so IO actions can be combined using either the do-notation
or the >> and >>= operations from the Monad class.
Instances
| Monad IO | Since: base-2.1 |
| Functor IO | Since: base-2.1 |
| MonadFail IO | Since: base-4.9.0.0 |
| Applicative IO | Since: base-2.1 |
| MonadIO IO | Since: base-4.9.0.0 |
| Alternative IO | Since: base-4.9.0.0 |
| MonadPlus IO | Since: base-4.9.0.0 |
| Semigroup a => Semigroup (IO a) | Since: base-4.10.0.0 |
| Monoid a => Monoid (IO a) | Since: base-4.9.0.0 |
class Applicative m => Monad (m :: Type -> Type) where Source #
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 Source #
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 Source #
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 :: String -> m a Source #
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 First | Since: base-4.8.0.0 |
| Monad Last | Since: base-4.8.0.0 |
| Monad ReadP | Since: base-2.1 |
| Monad NonEmpty | Since: base-4.9.0.0 |
| Monad P | Since: base-2.1 |
| Monad (Either e) | Since: base-4.4.0.0 |
| Monoid a => Monad ((,) a) | Since: base-4.9.0.0 |
| Monad m => Monad (WrappedMonad m) | Since: base-4.7.0.0 |
Defined in Control.Applicative Methods (>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b Source # (>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source # return :: a -> WrappedMonad m a Source # fail :: String -> WrappedMonad m a Source # | |
| Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
| Monad f => Monad (Ap f) | Since: base-4.12.0.0 |
| Monad ((->) r :: Type -> Type) | Since: base-2.1 |
| (Applicative f, Monad f) => Monad (WhenMissing f k x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal Methods (>>=) :: WhenMissing f k x a -> (a -> WhenMissing f k x b) -> WhenMissing f k x b Source # (>>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b Source # return :: a -> WhenMissing f k x a Source # fail :: String -> WhenMissing f k x a Source # | |
| (Monad f, Applicative f) => Monad (WhenMatched f k x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal Methods (>>=) :: WhenMatched f k x y a -> (a -> WhenMatched f k x y b) -> WhenMatched f k x y b Source # (>>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b Source # return :: a -> WhenMatched f k x y a Source # fail :: String -> WhenMatched f k x y a Source # | |
The Maybe type encapsulates an optional value. A value of type
either contains a value of type Maybe aa (represented as ),
or it is empty (represented as Just aNothing). Using Maybe is a good way to
deal with errors or exceptional cases without resorting to drastic
measures such as error.
The Maybe type is also a monad. It is a simple kind of error
monad, where all errors are represented by Nothing. A richer
error monad can be built using the Either type.
Instances
| Monad Maybe | Since: base-2.1 |
| Functor Maybe | Since: base-2.1 |
| MonadFail Maybe | Since: base-4.9.0.0 |
| Applicative Maybe | Since: base-2.1 |
| Foldable Maybe | Since: base-2.1 |
Defined in Data.Foldable Methods fold :: Monoid m => Maybe m -> m Source # foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source # foldr :: (a -> b -> b) -> b -> Maybe a -> b Source # foldr' :: (a -> b -> b) -> b -> Maybe a -> b Source # foldl :: (b -> a -> b) -> b -> Maybe a -> b Source # foldl' :: (b -> a -> b) -> b -> Maybe a -> b Source # foldr1 :: (a -> a -> a) -> Maybe a -> a Source # foldl1 :: (a -> a -> a) -> Maybe a -> a Source # toList :: Maybe a -> [a] Source # null :: Maybe a -> Bool Source # length :: Maybe a -> Int Source # elem :: Eq a => a -> Maybe a -> Bool Source # maximum :: Ord a => Maybe a -> a Source # minimum :: Ord a => Maybe a -> a Source # | |
| Traversable Maybe | Since: base-2.1 |
| Alternative Maybe | Since: base-2.1 |
| MonadPlus Maybe | Since: base-2.1 |
| Eq a => Eq (Maybe a) | Since: base-2.1 |
| Ord a => Ord (Maybe a) | Since: base-2.1 |
| Read a => Read (Maybe a) | Since: base-2.1 |
| Show a => Show (Maybe a) | Since: base-2.1 |
| Semigroup a => Semigroup (Maybe a) | Since: base-4.9.0.0 |
| Semigroup a => Monoid (Maybe a) | Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 |
| NullToNothing (Maybe a) Source # | |
Defined in Data.GI.Base.BasicTypes | |
| IsGVariant a => IsGVariant (Maybe a) Source # | |
Defined in Data.GI.Base.GVariant | |
| IsGValue (Maybe String) Source # | |
| IsGValue (Maybe Text) Source # | |
($) :: (a -> b) -> a -> b infixr 0 Source #
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
Note that ($) is levity-polymorphic in its result type, so that
foo $ True where foo :: Bool -> Int#
is well-typed
(++) :: [a] -> [a] -> [a] infixr 5 Source #
Append two lists, i.e.,
[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
If the first list is not finite, the result is the first list.
(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 Source #
Same as >>=, but with the arguments interchanged.
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 Source #
Left-to-right composition of Kleisli arrows.
Instances
Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.
Instances
| Eq Float | Note that due to the presence of
Also note that
|
| Floating Float | Since: base-2.1 |
Defined in GHC.Float Methods exp :: Float -> Float Source # log :: Float -> Float Source # sqrt :: Float -> Float Source # (**) :: Float -> Float -> Float Source # logBase :: Float -> Float -> Float Source # sin :: Float -> Float Source # cos :: Float -> Float Source # tan :: Float -> Float Source # asin :: Float -> Float Source # acos :: Float -> Float Source # atan :: Float -> Float Source # sinh :: Float -> Float Source # cosh :: Float -> Float Source # tanh :: Float -> Float Source # asinh :: Float -> Float Source # acosh :: Float -> Float Source # atanh :: Float -> Float Source # log1p :: Float -> Float Source # expm1 :: Float -> Float Source # | |
| Ord Float | Note that due to the presence of
Also note that, due to the same,
|
Defined in GHC.Classes | |
| Read Float | Since: base-2.1 |
| RealFloat Float | Since: base-2.1 |
Defined in GHC.Float Methods floatRadix :: Float -> Integer Source # floatDigits :: Float -> Int Source # floatRange :: Float -> (Int, Int) Source # decodeFloat :: Float -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> Float Source # exponent :: Float -> Int Source # significand :: Float -> Float Source # scaleFloat :: Int -> Float -> Float Source # isNaN :: Float -> Bool Source # isInfinite :: Float -> Bool Source # isDenormalized :: Float -> Bool Source # isNegativeZero :: Float -> Bool Source # | |
| Storable Float | Since: base-2.1 |
Defined in Foreign.Storable Methods sizeOf :: Float -> Int Source # alignment :: Float -> Int Source # peekElemOff :: Ptr Float -> Int -> IO Float Source # pokeElemOff :: Ptr Float -> Int -> Float -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Float Source # pokeByteOff :: Ptr b -> Int -> Float -> IO () Source # | |
| IsGValue Float Source # | |
| Foldable (URec Float :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => URec Float m -> m Source # foldMap :: Monoid m => (a -> m) -> URec Float a -> m Source # foldr :: (a -> b -> b) -> b -> URec Float a -> b Source # foldr' :: (a -> b -> b) -> b -> URec Float a -> b Source # foldl :: (b -> a -> b) -> b -> URec Float a -> b Source # foldl' :: (b -> a -> b) -> b -> URec Float a -> b Source # foldr1 :: (a -> a -> a) -> URec Float a -> a Source # foldl1 :: (a -> a -> a) -> URec Float a -> a Source # toList :: URec Float a -> [a] Source # null :: URec Float a -> Bool Source # length :: URec Float a -> Int Source # elem :: Eq a => a -> URec Float a -> Bool Source # maximum :: Ord a => URec Float a -> a Source # minimum :: Ord a => URec Float a -> a Source # | |
| Traversable (URec Float :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> URec Float a -> f (URec Float b) Source # sequenceA :: Applicative f => URec Float (f a) -> f (URec Float a) Source # mapM :: Monad m => (a -> m b) -> URec Float a -> m (URec Float b) Source # sequence :: Monad m => URec Float (m a) -> m (URec Float a) Source # | |
Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.
Instances
undefined :: HasCallStack => a Source #
map :: (a -> b) -> [a] -> [b] Source #
map f xs is the list obtained by applying f to each element
of xs, i.e.,
map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] map f [x1, x2, ...] == [f x1, f x2, ...]
length :: Foldable t => t a -> Int Source #
Returns the size/length of a finite structure as an Int. The
default implementation is optimized for structures that are similar to
cons-lists, because there is no general way to do better.
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) Source #
Map each element of a structure to a monadic action, evaluate
these actions from left to right, and collect the results. For
a version that ignores the results see mapM_.
when :: Applicative f => Bool -> f () -> f () Source #
Conditional execution of Applicative expressions. For example,
when debug (putStrLn "Debugging")
will output the string Debugging if the Boolean value debug
is True, and otherwise do nothing.
fromIntegral :: (Integral a, Num b) => a -> b Source #
general coercion from integral types
realToFrac :: (Real a, Fractional b) => a -> b Source #
general coercion to fractional types