Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- (:&=) :: (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed tag info obj, AttrTransferTypeConstraint info b, AttrSetTypeConstraint info (AttrTransferType info)) => AttrLabelProxy (attr :: Symbol) -> 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 AttrBaseTypeConstraint info :: * -> Constraint
- type AttrGetType info
- type AttrSetTypeConstraint info :: * -> Constraint
- type AttrTransferTypeConstraint info :: * -> Constraint
- type AttrTransferType info :: *
- type AttrLabel info :: Symbol
- type AttrOrigin info
- attrGet :: AttrBaseTypeConstraint info o => o -> IO (AttrGetType info)
- attrSet :: (AttrBaseTypeConstraint info o, AttrSetTypeConstraint info b) => o -> b -> IO ()
- attrClear :: AttrBaseTypeConstraint info o => o -> IO ()
- attrConstruct :: (AttrBaseTypeConstraint info o, AttrSetTypeConstraint info b) => b -> IO (GValueConstruct o)
- attrTransfer :: forall o b. (AttrBaseTypeConstraint info o, AttrTransferTypeConstraint info b) => Proxy o -> b -> IO (AttrTransferType info)
- 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
- data GClosure a
- 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
- data GObjectNotifySignalInfo
- data SignalConnectMode
- class SignalInfo (info :: *) where
- type HaskellCallbackType info :: *
- connectSignal :: GObject o => o -> HaskellCallbackType info -> SignalConnectMode -> Maybe Text -> IO SignalHandlerId
- type SignalHandlerId = CULong
- connectSignalFunPtr :: GObject o => o -> Text -> FunPtr a -> SignalConnectMode -> Maybe Text -> 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
- ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (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 :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a
- error :: forall (r :: RuntimeRep) (a :: TYPE r). 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
Bounded Char | Since: base-2.1 |
Enum Char | Since: base-2.1 |
Eq Char | |
Ord Char | |
Read Char | Since: base-2.1 |
Show Char | Since: base-2.1 |
Storable Char | Since: base-2.1 |
Defined in Foreign.Storable | |
IsGValue (Maybe String) Source # | |
Foldable (URec Char :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => URec Char m -> m # foldMap :: Monoid m => (a -> m) -> URec Char a -> m # foldMap' :: Monoid m => (a -> m) -> URec Char a -> m # foldr :: (a -> b -> b) -> b -> URec Char a -> b # foldr' :: (a -> b -> b) -> b -> URec Char a -> b # foldl :: (b -> a -> b) -> b -> URec Char a -> b # foldl' :: (b -> a -> b) -> b -> URec Char a -> b # foldr1 :: (a -> a -> a) -> URec Char a -> a # foldl1 :: (a -> a -> a) -> URec Char a -> a # toList :: URec Char a -> [a] # length :: URec Char a -> Int # elem :: Eq a => a -> URec Char a -> Bool # maximum :: Ord a => URec Char a -> a # minimum :: Ord a => URec Char a -> a # | |
Traversable (URec Char :: Type -> Type) | Since: base-4.9.0.0 |
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
Bounded Int | Since: base-2.1 |
Enum Int | Since: base-2.1 |
Eq Int | |
Integral Int | Since: base-2.0.1 |
Num Int | Since: base-2.1 |
Ord Int | |
Read Int | Since: base-2.1 |
Real Int | Since: base-2.0.1 |
Defined in GHC.Real toRational :: Int -> Rational # | |
Show Int | Since: base-2.1 |
Storable Int | Since: base-2.1 |
Defined in Foreign.Storable | |
Bits Int | Since: base-2.1 |
Defined in Data.Bits | |
FiniteBits Int | Since: base-4.6.0.0 |
Defined in Data.Bits | |
Foldable (URec Int :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => URec Int m -> m # foldMap :: Monoid m => (a -> m) -> URec Int a -> m # foldMap' :: Monoid m => (a -> m) -> URec Int a -> m # foldr :: (a -> b -> b) -> b -> URec Int a -> b # foldr' :: (a -> b -> b) -> b -> URec Int a -> b # foldl :: (b -> a -> b) -> b -> URec Int a -> b # foldl' :: (b -> a -> b) -> b -> URec Int a -> b # foldr1 :: (a -> a -> a) -> URec Int a -> a # foldl1 :: (a -> a -> a) -> URec Int a -> a # elem :: Eq a => a -> URec Int a -> Bool # maximum :: Ord a => URec Int a -> a # minimum :: Ord a => URec Int a -> a # | |
Traversable (URec Int :: Type -> Type) | Since: base-4.9.0.0 |
8-bit signed integer type
Instances
Bounded Int8 | Since: base-2.1 |
Enum Int8 | Since: base-2.1 |
Eq Int8 | Since: base-2.1 |
Integral Int8 | Since: base-2.1 |
Num Int8 | Since: base-2.1 |
Ord Int8 | Since: base-2.1 |
Read Int8 | Since: base-2.1 |
Real Int8 | Since: base-2.1 |
Defined in GHC.Int toRational :: Int8 -> Rational # | |
Show Int8 | Since: base-2.1 |
Ix Int8 | Since: base-2.1 |
Storable Int8 | Since: base-2.1 |
Defined in Foreign.Storable | |
Bits Int8 | Since: base-2.1 |
Defined in GHC.Int (.&.) :: Int8 -> Int8 -> Int8 # (.|.) :: Int8 -> Int8 -> Int8 # complement :: Int8 -> Int8 # shift :: Int8 -> Int -> Int8 # rotate :: Int8 -> Int -> Int8 # setBit :: Int8 -> Int -> Int8 # clearBit :: Int8 -> Int -> Int8 # complementBit :: Int8 -> Int -> Int8 # testBit :: Int8 -> Int -> Bool # bitSizeMaybe :: Int8 -> Maybe Int # shiftL :: Int8 -> Int -> Int8 # unsafeShiftL :: Int8 -> Int -> Int8 # shiftR :: Int8 -> Int -> Int8 # unsafeShiftR :: Int8 -> Int -> Int8 # rotateL :: Int8 -> Int -> Int8 # | |
FiniteBits Int8 | Since: base-4.6.0.0 |
Defined in GHC.Int |
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 #
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
Haskell type representing the C int
type.
Instances
Bounded CInt | |
Enum CInt | |
Eq CInt | |
Integral CInt | |
Num CInt | |
Ord CInt | |
Read CInt | |
Real CInt | |
Defined in Foreign.C.Types toRational :: CInt -> Rational # | |
Show CInt | |
Storable CInt | |
Defined in Foreign.C.Types | |
Bits CInt | |
Defined in Foreign.C.Types (.&.) :: CInt -> CInt -> CInt # (.|.) :: CInt -> CInt -> CInt # complement :: CInt -> CInt # shift :: CInt -> Int -> CInt # rotate :: CInt -> Int -> CInt # setBit :: CInt -> Int -> CInt # clearBit :: CInt -> Int -> CInt # complementBit :: CInt -> Int -> CInt # testBit :: CInt -> Int -> Bool # bitSizeMaybe :: CInt -> Maybe Int # shiftL :: CInt -> Int -> CInt # unsafeShiftL :: CInt -> Int -> CInt # shiftR :: CInt -> Int -> CInt # unsafeShiftR :: CInt -> Int -> CInt # rotateL :: CInt -> Int -> CInt # | |
FiniteBits CInt | |
Defined in Foreign.C.Types | |
IsGValue CInt Source # | |
Haskell type representing the C unsigned int
type.
Instances
Bounded CUInt | |
Enum CUInt | |
Eq CUInt | |
Integral CUInt | |
Num CUInt | |
Ord CUInt | |
Read CUInt | |
Real CUInt | |
Defined in Foreign.C.Types toRational :: CUInt -> Rational # | |
Show CUInt | |
Storable CUInt | |
Bits CUInt | |
Defined in Foreign.C.Types (.&.) :: CUInt -> CUInt -> CUInt # (.|.) :: CUInt -> CUInt -> CUInt # xor :: CUInt -> CUInt -> CUInt # complement :: CUInt -> CUInt # shift :: CUInt -> Int -> CUInt # rotate :: CUInt -> Int -> CUInt # setBit :: CUInt -> Int -> CUInt # clearBit :: CUInt -> Int -> CUInt # complementBit :: CUInt -> Int -> CUInt # testBit :: CUInt -> Int -> Bool # bitSizeMaybe :: CUInt -> Maybe Int # shiftL :: CUInt -> Int -> CUInt # unsafeShiftL :: CUInt -> Int -> CUInt # shiftR :: CUInt -> Int -> CUInt # unsafeShiftR :: CUInt -> Int -> CUInt # rotateL :: CUInt -> Int -> CUInt # | |
FiniteBits CUInt | |
Defined in Foreign.C.Types finiteBitSize :: CUInt -> Int # countLeadingZeros :: CUInt -> Int # countTrailingZeros :: CUInt -> Int # | |
IsGValue CUInt Source # | |
Haskell type representing the C long
type.
Instances
Bounded CLong | |
Enum CLong | |
Eq CLong | |
Integral CLong | |
Num CLong | |
Ord CLong | |
Read CLong | |
Real CLong | |
Defined in Foreign.C.Types toRational :: CLong -> Rational # | |
Show CLong | |
Storable CLong | |
Bits CLong | |
Defined in Foreign.C.Types (.&.) :: CLong -> CLong -> CLong # (.|.) :: CLong -> CLong -> CLong # xor :: CLong -> CLong -> CLong # complement :: CLong -> CLong # shift :: CLong -> Int -> CLong # rotate :: CLong -> Int -> CLong # setBit :: CLong -> Int -> CLong # clearBit :: CLong -> Int -> CLong # complementBit :: CLong -> Int -> CLong # testBit :: CLong -> Int -> Bool # bitSizeMaybe :: CLong -> Maybe Int # shiftL :: CLong -> Int -> CLong # unsafeShiftL :: CLong -> Int -> CLong # shiftR :: CLong -> Int -> CLong # unsafeShiftR :: CLong -> Int -> CLong # rotateL :: CLong -> Int -> CLong # | |
FiniteBits CLong | |
Defined in Foreign.C.Types finiteBitSize :: CLong -> Int # countLeadingZeros :: CLong -> Int # countTrailingZeros :: CLong -> Int # | |
IsGValue CLong Source # | |
Haskell type representing the C unsigned long
type.
Instances
Haskell type representing the C float
type.
Instances
Enum CFloat | |
Defined in Foreign.C.Types | |
Eq CFloat | |
Floating CFloat | |
Fractional CFloat | |
Num CFloat | |
Ord CFloat | |
Read CFloat | |
Real CFloat | |
Defined in Foreign.C.Types toRational :: CFloat -> Rational # | |
RealFloat CFloat | |
Defined in Foreign.C.Types floatRadix :: CFloat -> Integer # floatDigits :: CFloat -> Int # floatRange :: CFloat -> (Int, Int) # decodeFloat :: CFloat -> (Integer, Int) # encodeFloat :: Integer -> Int -> CFloat # significand :: CFloat -> CFloat # scaleFloat :: Int -> CFloat -> CFloat # isInfinite :: CFloat -> Bool # isDenormalized :: CFloat -> Bool # isNegativeZero :: CFloat -> Bool # | |
RealFrac CFloat | |
Show CFloat | |
Storable CFloat | |
Haskell type representing the C double
type.
Instances
Enum CDouble | |
Eq CDouble | |
Floating CDouble | |
Fractional CDouble | |
Num CDouble | |
Ord CDouble | |
Read CDouble | |
Real CDouble | |
Defined in Foreign.C.Types toRational :: CDouble -> Rational # | |
RealFloat CDouble | |
Defined in Foreign.C.Types floatRadix :: CDouble -> Integer # floatDigits :: CDouble -> Int # floatRange :: CDouble -> (Int, Int) # decodeFloat :: CDouble -> (Integer, Int) # encodeFloat :: Integer -> Int -> CDouble # significand :: CDouble -> CDouble # scaleFloat :: Int -> CDouble -> CDouble # isInfinite :: CDouble -> Bool # isDenormalized :: CDouble -> Bool # isNegativeZero :: CDouble -> Bool # | |
RealFrac CDouble | |
Show CDouble | |
Storable CDouble | |
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 |
Show (Ptr a) | Since: base-2.1 |
Storable (Ptr a) | Since: base-2.1 |
IsGValue (Ptr a) Source # | |
Foldable (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => URec (Ptr ()) m -> m # foldMap :: Monoid m => (a -> m) -> URec (Ptr ()) a -> m # foldMap' :: Monoid m => (a -> m) -> URec (Ptr ()) a -> m # foldr :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b # foldr' :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b # foldl :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b # foldl' :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b # foldr1 :: (a -> a -> a) -> URec (Ptr ()) a -> a # foldl1 :: (a -> a -> a) -> URec (Ptr ()) a -> a # toList :: URec (Ptr ()) a -> [a] # null :: URec (Ptr ()) a -> Bool # length :: URec (Ptr ()) a -> Int # elem :: Eq a => a -> URec (Ptr ()) a -> Bool # maximum :: Ord a => URec (Ptr ()) a -> a # minimum :: Ord a => URec (Ptr ()) a -> a # | |
Traversable (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Traversable |
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
,
,Ptr
a
,FunPtr
a
or a renaming of any of these usingStablePtr
anewtype
. - the return type is either a marshallable foreign type or has the form
whereIO
tt
is 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) | |
Show (FunPtr a) | Since: base-2.1 |
Storable (FunPtr a) | Since: base-2.1 |
Defined in Foreign.Storable |
castPtrToFunPtr :: Ptr a -> FunPtr b #
castFunPtrToPtr :: FunPtr a -> Ptr b #
data ForeignPtr a #
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 ForeignPtr
s 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 (==) :: ForeignPtr a -> ForeignPtr a -> Bool # (/=) :: ForeignPtr a -> ForeignPtr a -> Bool # | |
Ord (ForeignPtr a) | Since: base-2.1 |
Defined in GHC.ForeignPtr compare :: ForeignPtr a -> ForeignPtr a -> Ordering # (<) :: ForeignPtr a -> ForeignPtr a -> Bool # (<=) :: ForeignPtr a -> ForeignPtr a -> Bool # (>) :: ForeignPtr a -> ForeignPtr a -> Bool # (>=) :: ForeignPtr a -> ForeignPtr a -> Bool # max :: ForeignPtr a -> ForeignPtr a -> ForeignPtr a # min :: ForeignPtr a -> ForeignPtr a -> ForeignPtr a # | |
Show (ForeignPtr a) | Since: base-2.1 |
Defined in GHC.ForeignPtr showsPrec :: Int -> ForeignPtr a -> ShowS # show :: ForeignPtr a -> String # showList :: [ForeignPtr a] -> ShowS # |
unsafeForeignPtrToPtr :: ForeignPtr a -> Ptr a #
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 #
Computes the storage requirements (in bytes) of the argument. The value of the argument is not used.
peek :: Storable a => Ptr a -> IO a #
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 () #
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 #
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
String
show
:
>>>
show <$> Nothing
Nothing>>>
show <$> Just 3
Just "3"
Convert from an
to an
Either
Int
Int
Either
Int
String
using show
:
>>>
show <$> Left 17
Left 17>>>
show <$> Right 17
Right "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 #
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.
(:=) :: (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 |
(:&=) :: (HasAttributeList obj, info ~ ResolveAttribute attr obj, AttrInfo info, AttrBaseTypeConstraint info obj, AttrOpAllowed tag info obj, AttrTransferTypeConstraint info b, AttrSetTypeConstraint info (AttrTransferType info)) => AttrLabelProxy (attr :: Symbol) -> b -> AttrOp obj tag | Assign a value to an attribute, allocating any necessary
memory for representing the Haskell value as a C value. Note
that it is the responsibility of the caller to make sure that
the memory is freed when no longer used, otherwise there will
be a memory leak. In the majority of cases you probably want to
use |
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.
AttrGet | It is possible to read the value of the attribute
with |
AttrSet | It is possible to write the value of the attribute
with |
AttrConstruct | It is possible to set the value of the attribute
in |
AttrClear | It is possible to clear the value of the
(nullable) attribute with |
Instances
Bounded AttrOpTag Source # | |
Enum AttrOpTag Source # | |
Defined in Data.GI.Base.Attributes succ :: AttrOpTag -> AttrOpTag # pred :: AttrOpTag -> AttrOpTag # fromEnum :: AttrOpTag -> Int # enumFrom :: AttrOpTag -> [AttrOpTag] # enumFromThen :: AttrOpTag -> AttrOpTag -> [AttrOpTag] # enumFromTo :: AttrOpTag -> AttrOpTag -> [AttrOpTag] # enumFromThenTo :: AttrOpTag -> AttrOpTag -> AttrOpTag -> [AttrOpTag] # | |
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.
AttrOpAllowed tag info useType = AttrOpIsAllowed tag (AttrAllowedOps info) (AttrLabel info) (AttrOrigin info) useType |
class AttrInfo (info :: *) where Source #
Info describing an attribute.
Nothing
type AttrAllowedOps info :: [AttrOpTag] Source #
The operations that are allowed on the attribute.
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 AttrSetTypeConstraint info :: * -> Constraint Source #
Constraint on the value being set.
type AttrSetTypeConstraint info = (~) (AttrGetType info) Source #
type AttrTransferTypeConstraint info :: * -> Constraint Source #
Constraint on the value being set, with allocation allowed
(see :&=
below).
type AttrTransferTypeConstraint info = (~) (AttrTransferType info) Source #
type AttrTransferType info :: * Source #
Type resulting from the allocation.
type AttrTransferType info = AttrGetType info Source #
type AttrLabel info :: Symbol Source #
Name of the attribute.
type AttrOrigin info Source #
Type which introduces the attribute.
attrGet :: AttrBaseTypeConstraint info o => o -> IO (AttrGetType info) Source #
Get the value of the given attribute.
default attrGet :: CheckNotElem 'AttrGet (AttrAllowedOps info) (GetNotProvidedError info) => o -> IO (AttrGetType info) Source #
attrSet :: (AttrBaseTypeConstraint info o, AttrSetTypeConstraint info b) => o -> b -> IO () Source #
Set the value of the given attribute, after the object having the attribute has already been created.
default attrSet :: CheckNotElem 'AttrSet (AttrAllowedOps info) (SetNotProvidedError info) => o -> b -> IO () Source #
attrClear :: AttrBaseTypeConstraint info o => o -> IO () Source #
Set the value of the given attribute to NULL
(for nullable
attributes).
default attrClear :: CheckNotElem 'AttrClear (AttrAllowedOps info) (ClearNotProvidedError info) => o -> IO () Source #
attrConstruct :: (AttrBaseTypeConstraint info o, AttrSetTypeConstraint info b) => b -> IO (GValueConstruct o) Source #
Build a GValue
representing the attribute.
default attrConstruct :: CheckNotElem 'AttrConstruct (AttrAllowedOps info) (ConstructNotProvidedError info) => b -> IO (GValueConstruct o) Source #
attrTransfer :: forall o b. (AttrBaseTypeConstraint info o, AttrTransferTypeConstraint info b) => Proxy o -> b -> IO (AttrTransferType info) Source #
Allocate memory as necessary to generate a settable type from the transfer type. This is useful for types which needs allocations for marshalling from Haskell to C, this makes the allocation explicit.
default attrTransfer :: forall o b. (AttrBaseTypeConstraint info o, AttrTransferTypeConstraint info b, b ~ AttrGetType info, b ~ AttrTransferType info) => Proxy o -> b -> IO (AttrTransferType info) Source #
data AttrLabelProxy (a :: Symbol) Source #
A proxy for attribute labels.
Instances
a ~ x => IsLabel x (AttrLabelProxy a) Source # | |
Defined in Data.GI.Base.Attributes fromLabel :: AttrLabelProxy a # |
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
The basic type. This corresponds to a wrapped GClosure
on the C
side, which is a boxed object.
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
data GObjectNotifySignalInfo Source #
Connection information for a "notify" signal indicating that a
specific property changed (see PropertyNotify
for the relevant
constructor).
Instances
SignalInfo GObjectNotifySignalInfo Source # | |
Defined in Data.GI.Base.Signals connectSignal :: GObject o => o -> HaskellCallbackType GObjectNotifySignalInfo -> SignalConnectMode -> Maybe Text -> IO SignalHandlerId Source # | |
type HaskellCallbackType GObjectNotifySignalInfo 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.
SignalConnectBefore | Run before the default handler. |
SignalConnectAfter | Run after the default handler. |
class SignalInfo (info :: *) where Source #
Information about an overloaded signal.
type HaskellCallbackType info :: * Source #
The type for the signal handler.
connectSignal :: GObject o => o -> HaskellCallbackType info -> SignalConnectMode -> Maybe Text -> 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
SignalInfo GObjectNotifySignalInfo Source # | |
Defined in Data.GI.Base.Signals connectSignal :: GObject o => o -> HaskellCallbackType GObjectNotifySignalInfo -> SignalConnectMode -> Maybe Text -> IO SignalHandlerId Source # |
type SignalHandlerId = CULong Source #
Type of a GObject
signal handler id.
connectSignalFunPtr :: GObject o => o -> Text -> FunPtr a -> SignalConnectMode -> Maybe Text -> IO SignalHandlerId Source #
Connect a signal to a handler, given as a FunPtr
.
module Data.GI.Base.Utils
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
Convert from an Int
.