query
On this page

mkDictionaryEntry

lib.gvariant.mkDictionaryEntry

Docs pulled from | This Revision | 14 minutes ago


Returns the GVariant dictionary entry from the given key and value.

Inputs

name

The key of the entry

value

The value of the entry

Type

mkDictionaryEntry :: String -> Any -> gvariant

Examples

lib.gvariant.mkDictionaryEntry usage example

# A dictionary describing an Epiphany’s search provider
[
  (lib.gvariant.mkDictionaryEntry "url" (lib.gvariant.mkVariant "https://duckduckgo.com/?q=%s&t=epiphany"))
  (lib.gvariant.mkDictionaryEntry "bang" (lib.gvariant.mkVariant "!d"))
  (lib.gvariant.mkDictionaryEntry "name" (lib.gvariant.mkVariant "DuckDuckGo"))
]

Noogle detected

Implementation

The following is the current implementation of this function.

mkDictionaryEntry =
    name: value:
    let
      name' = mkValue name;
      value' = mkValue value;
      dictionaryType = type.dictionaryEntryOf name'.type value'.type;
    in
    mkPrimitive dictionaryType { inherit name value; }
    // {
      __toString = self: "@${self.type} {${name'},${value'}}";
    };