Safe Haskell | None |
---|---|
Language | Haskell98 |
Helpers for dealing with GObject
s.
- type family ParentTypes a :: [*]
- type family IsDescendantOf parent descendant :: Constraint
- type family AttributeList a :: [(Symbol, *)]
- type family ResolveAttribute s o :: *
- type family HasAttribute attr o
- class HasAttr attr o
- type family SignalList a :: [(Symbol, *)]
- type family ResolveSignal s o :: *
- type family HasSignal s o
- class MethodInfo i o s where
- overloadedMethod :: MethodProxy i -> o -> s
- data MethodProxy a = MethodProxy
- data MethodResolutionFailed label o
- class IsLabelProxy x a where
- fromLabelProxy :: Proxy x -> a
Type level inheritance
type family ParentTypes a :: [*] Source
The direct parents of this object: its direct parent type, if any, and the interfaces it implements. The interfaces inherited from parent types can be omitted.
type family IsDescendantOf parent descendant :: Constraint Source
Check that a type is in the list of GObjectParents
of another
GObject
-derived type.
IsDescendantOf d d = () ~ () | |
IsDescendantOf p d = CheckForAncestorType d p (ParentTypes d) ~ HasAncestor p d |
Looking up attributes in parent types
type family AttributeList a :: [(Symbol, *)] Source
The list of attributes defined for a given type. Each element of
the list is a tuple, with the first element of the tuple the name
of the attribute, and the second the type encoding the information
of the attribute. This type will be an instance of AttrInfo
.
type family ResolveAttribute s o :: * Source
Return the type encoding the attribute information for a given type and attribute.
ResolveAttribute s o = FindElement s (AttributeList o) (UnknownAttribute "Error: could not find attribute" s "for object" o) |
type family HasAttribute attr o Source
A constraint imposing that the given object has the given attribute.
HasAttribute attr o = IsElem attr (AttributeList o) HasAttribute (DoesNotHaveAttribute "Error: attribute" attr "not found for type" o) ~ HasAttribute |
A constraint that enforces that the given type has a given attribute.
HasAttribute attr o => HasAttr attr o |
Looking up signals in parent types
type family SignalList a :: [(Symbol, *)] Source
The list of signals defined for a given type. Each element of
the list is a tuple, with the first element of the tuple the name
of the signal, and the second the type encoding the information of
the signal. This type will be an instance of SignalInfo
.
type family ResolveSignal s o :: * Source
Return the type encoding the signal information for a given type and signal.
ResolveSignal s o = FindElement s (SignalList o) (UnknownSignal "Error: could not find signal" s "for object" o) |
type family HasSignal s o Source
A constraint enforcing that the signal exists for the given object, or one of its ancestors.
HasSignal s o = IsElem s (SignalList o) HasSignal (DoesNotHaveSignal "Error: signal" s "not found for type" o) ~ HasSignal |
Looking up methods in parent types
class MethodInfo i o s where Source
Class for types containing the information about an overloaded method of type `o -> s`.
overloadedMethod :: MethodProxy i -> o -> s Source
data MethodProxy a Source
Proxy for passing a type to overloadedMethod
. We do not use
Proxy
directly since it clashes with types defined in
the autogenerated bindings.
data MethodResolutionFailed label o Source
Datatype returned when the method is not found, hopefully making the resulting error messages somewhat clearer.
Overloaded labels
class IsLabelProxy x a where Source
Support for overloaded labels in ghc < 8.0. This is like the
IsLabel
class introduced in ghc 8.0 (for use with the
OverloadedLabels extension) with the difference that the Proxy
argument is lifted. (Using the unlifted Proxy# type in user code is
a bit of a pain, hence the choice.)
fromLabelProxy :: Proxy x -> a Source
(~) Symbol a x => IsLabelProxy x (AttrLabelProxy a) | Support for overloaded labels. |
(HasSignal slot object, (~) * info (ResolveSignal slot object)) => IsLabelProxy slot (SignalProxy object info) | Support for overloaded labels. |