haskell-gi-base-0.26.9: Foundation for libraries generated by haskell-gi

Safe Haskell | None
Language | Haskell2010

Data.GI.Base.Overloading

Contents

- Type level inheritance
- Looking up attributes in parent types
- Looking up signals in parent types
- Looking up methods in parent types

Description

Helpers for dealing with overladed properties, signals and methods.

Synopsis

- type family ParentTypes a :: [Type]
- class HasParentTypes o
- type family IsDescendantOf parent descendant where ...
- asA :: (ManagedPtrNewtype a, ManagedPtrNewtype b, HasParentTypes b, IsDescendantOf a b) => b -> (ManagedPtr a -> a) -> a
- type family AttributeList a :: [(Symbol, Type)]
- class HasAttributeList (a :: k)
- type family ResolveAttribute (s :: Symbol) o where ...
- type family HasAttribute (attr :: Symbol) o where ...
- class HasAttr (attr :: Symbol) o
- type family SignalList a :: [(Symbol, Type)]
- type family ResolveSignal (s :: Symbol) o where ...
- type family HasSignal (s :: Symbol) o where ...
- type family MethodResolutionFailed (method :: Symbol) o :: k where ...
- type family UnsupportedMethodError (s :: Symbol) o where ...
- class OverloadedMethodInfo (i :: k) (o :: k1) where
  - overloadedMethodInfo :: Maybe ResolvedSymbolInfo
- class OverloadedMethod (i :: k) o s where
  - overloadedMethod :: o -> s
- data MethodProxy info obj = MethodProxy
- data ResolvedSymbolInfo = ResolvedSymbolInfo {
  - resolvedSymbolName :: Text
  - resolvedSymbolURL :: Text
  }
- resolveMethod :: OverloadedMethodInfo info obj => obj -> MethodProxy info obj -> Maybe ResolvedSymbolInfo

# Type level inheritance

type family ParentTypes a :: [Type] Source #

All the types that are ascendants of this type, including interfaces that the type implements.

#### Instances

Instances details

type ParentTypes GError Source # | There are no types in the bindings that a `GError` can be safely cast to.
Instance details Defined in Data.GI.Base.GError type ParentTypes GError = '[] :: [Type]
type ParentTypes GValue Source # | There are no types in the bindings that a `GValue` can be safely cast to.
Instance details Defined in Data.GI.Base.GValue type ParentTypes GValue = '[] :: [Type]
type ParentTypes (GClosure a) Source # | There are no types in the bindings that a closure can be safely cast to.
Instance details Defined in Data.GI.Base.GClosure type ParentTypes (GClosure a) = '[] :: [Type]

class HasParentTypes o Source #

A constraint on a type, to be fulfilled whenever it has a type instance for `ParentTypes`. This leads to nicer errors, thanks to the overlappable instance below.

#### Instances

Instances details

HasParentTypes GError Source # |
Instance details Defined in Data.GI.Base.GError
HasParentTypes GValue Source # |
Instance details Defined in Data.GI.Base.GValue
(TypeError (('Text "Type \8216" ':<>: 'ShowType a) ':<>: 'Text "\8217 does not have any known parent types.") :: Constraint) => HasParentTypes a Source # | Default instance, which will give rise to an error for types without an associated `ParentTypes` instance.
Instance details Defined in Data.GI.Base.Overloading
HasParentTypes (GClosure a) Source # |
Instance details Defined in Data.GI.Base.GClosure

type family IsDescendantOf parent descendant where ... Source #

Check that a type is in the list of `ParentTypes` of another type.

Equations

IsDescendantOf d d = () |
IsDescendantOf p d = CheckForAncestorType d p (ParentTypes d) |

asA :: (ManagedPtrNewtype a, ManagedPtrNewtype b, HasParentTypes b, IsDescendantOf a b) => b -> (ManagedPtr a -> a) -> a Source #

Safe coercions to a parent class. For instance:

    #show $ label `asA` Gtk.Widget

# Looking up attributes in parent types

type family AttributeList a :: [(Symbol, Type)] 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`.

class HasAttributeList (a :: k) Source #

A constraint on a type, to be fulfilled whenever it has a type instance for `AttributeList`. This is here for nicer error reporting.

#### Instances

Instances details

(TypeError (('Text "Type \8216" ':<>: 'ShowType a) ':<>: 'Text "\8217 does not have any known attributes.") :: Constraint) => HasAttributeList (a :: k) Source # | Default instance, which will give rise to an error for types without an associated `AttributeList`.
Instance details Defined in Data.GI.Base.Overloading

type family ResolveAttribute (s :: Symbol) o where ... Source #

Return the type encoding the attribute information for a given type and attribute.

Equations

ResolveAttribute s o = FindElement s (AttributeList o) (((('Text "Unknown attribute \8216" ':<>: 'Text s) ':<>: 'Text "\8217 for object \8216") ':<>: 'ShowType o) ':<>: 'Text "\8217.") |

type family HasAttribute (attr :: Symbol) o where ... Source #

A constraint imposing that the given object has the given attribute.

Equations

HasAttribute attr o = IsElem attr (AttributeList o) () (((('Text "Attribute \8216" ':<>: 'Text attr) ':<>: 'Text "\8217 not found for type \8216") ':<>: 'ShowType o) ':<>: 'Text "\8217.") |

class HasAttr (attr :: Symbol) o Source #

A constraint that enforces that the given type has a given attribute.

#### Instances

Instances details

HasAttribute attr o => HasAttr attr o Source # |
Instance details Defined in Data.GI.Base.Overloading

# Looking up signals in parent types

type family SignalList a :: [(Symbol, Type)] 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 :: Symbol) o where ... Source #

Return the type encoding the signal information for a given type and signal.

Equations

ResolveSignal s o = FindElement s (SignalList o) (((('Text "Unknown signal \8216" ':<>: 'Text s) ':<>: 'Text "\8217 for object \8216") ':<>: 'ShowType o) ':<>: 'Text "\8217.") |

type family HasSignal (s :: Symbol) o where ... Source #

A constraint enforcing that the signal exists for the given object, or one of its ancestors.

Equations

HasSignal s o = IsElem s (SignalList o) () (((('Text "Signal \8216" ':<>: 'Text s) ':<>: 'Text "\8217 not found for type \8216") ':<>: 'ShowType o) ':<>: 'Text "\8217.") |

# Looking up methods in parent types

type family MethodResolutionFailed (method :: Symbol) o :: k where ... Source #

Returned when the method is not found, hopefully making the resulting error messages somewhat clearer.

Equations

MethodResolutionFailed m o = TypeError (((('Text "Unknown method \8216" ':<>: 'Text m) ':<>: 'Text "\8217 for type \8216") ':<>: 'ShowType o) ':<>: 'Text "\8217.") :: k |

type family UnsupportedMethodError (s :: Symbol) o where ... Source #

A constraint that always fails with a type error, for documentation purposes.

Equations

UnsupportedMethodError s o = TypeError (((('Text "Unsupported method \8216" ':<>: 'Text s) ':<>: 'Text "\8217 for object \8216") ':<>: 'ShowType o) ':<>: 'Text "\8217.") :: Type |

class OverloadedMethodInfo (i :: k) (o :: k1) where Source #

This is for debugging purposes, see `resolveMethod` below.

Methods

overloadedMethodInfo :: Maybe ResolvedSymbolInfo Source #

class OverloadedMethod (i :: k) o s where Source #

Class for types containing the information about an overloaded method of type `o -> s`.

Methods

overloadedMethod Source #

Arguments

:: o |
-> s | The actual method being invoked.

data MethodProxy info obj Source #

A proxy for carrying the types `MethodInfoName` needs (this is used for `resolveMethod`, see below).

Constructors

MethodProxy |

data ResolvedSymbolInfo Source #

Information about a fully resolved symbol, for debugging purposes.

Constructors

ResolvedSymbolInfo |

Fields

- resolvedSymbolName :: Text
- resolvedSymbolURL :: Text

#### Instances

Instances details

Show ResolvedSymbolInfo Source # |
Instance details Defined in Data.GI.Base.Overloading Methods showsPrec :: Int -> ResolvedSymbolInfo -> ShowS Source # show :: ResolvedSymbolInfo -> String Source # showList :: [ResolvedSymbolInfo] -> ShowS Source #

resolveMethod :: OverloadedMethodInfo info obj => obj -> MethodProxy info obj -> Maybe ResolvedSymbolInfo Source #

Return the fully qualified method name that a given overloaded method call resolves to (mostly useful for debugging).

    resolveMethod widget #show