Ide.Plugin.Properties

hls-plugin-api-2.9.0.0: Haskell Language Server API for plugin communication

Safe Haskell | None
Language | GHC2021

Ide.Plugin.Properties

Synopsis

- data PropertyType
  - = TNumber
  - | TInteger
  - | TString
  - | TBoolean
  - | TObject Type
  - | TArray Type
  - | TEnum Type
  - | TProperties [PropertyKey]
- type family ToHsType (t :: PropertyType) where ...
- type family NotElem (s :: Symbol) (r :: [PropertyKey]) where ...
- data MetaData (t :: PropertyType) where
  - MetaData :: forall (t :: PropertyType). (IsTEnum t ~ 'False, IsProperties t ~ 'False) => {..} -> MetaData t
  - EnumMetaData :: forall (t :: PropertyType). IsTEnum t ~ 'True => {..} -> MetaData t
  - PropertiesMetaData :: forall (t :: PropertyType) (rs :: [PropertyKey]). t ~ 'TProperties rs => {..} -> MetaData t
- data PropertyKey = PropertyKey Symbol PropertyType
- data SPropertyKey (k :: PropertyKey) where
  - SNumber :: forall (s :: Symbol). SPropertyKey ('PropertyKey s 'TNumber)
  - SInteger :: forall (s :: Symbol). SPropertyKey ('PropertyKey s 'TInteger)
  - SString :: forall (s :: Symbol). SPropertyKey ('PropertyKey s 'TString)
  - SBoolean :: forall (s :: Symbol). SPropertyKey ('PropertyKey s 'TBoolean)
  - SObject :: forall a (s :: Symbol). (ToJSON a, FromJSON a) => Proxy a -> SPropertyKey ('PropertyKey s ('TObject a))
  - SArray :: forall a (s :: Symbol). (ToJSON a, FromJSON a) => Proxy a -> SPropertyKey ('PropertyKey s ('TArray a))
  - SEnum :: forall a (s :: Symbol). (ToJSON a, FromJSON a, Eq a, Show a) => Proxy a -> SPropertyKey ('PropertyKey s ('TEnum a))
  - SProperties :: forall (s :: Symbol) (pp :: [PropertyKey]). SPropertyKey ('PropertyKey s ('TProperties pp))
- data KeyNameProxy (s :: Symbol) = KnownSymbol s => KeyNameProxy
- data KeyNamePath (r :: NonEmptyList Symbol) where
  - SingleKey :: forall (s :: Symbol). KeyNameProxy s -> KeyNamePath ('NE s)
  - ConsKeysPath :: forall (s1 :: Symbol) (ss :: NonEmptyList Symbol). KeyNameProxy s1 -> KeyNamePath ss -> KeyNamePath (s1 ':| ss)
- data Properties (r :: [PropertyKey])
- type HasProperty (s :: Symbol) (k :: PropertyKey) (t :: PropertyType) (r :: [PropertyKey]) = (k ~ 'PropertyKey s t, Elem s r, FindByKeyPath ('NE s) r ~ t, FindByKeyName s r ~ t, KnownSymbol s, FindPropertyMeta s r t)
- type HasPropertyByPath (props :: [PropertyKey]) (path :: NonEmptyList Symbol) (t :: PropertyType) = (t ~ FindByKeyPath path props, ParsePropertyPath props path)
- emptyProperties :: Properties ('[] :: [PropertyKey])
- defineNumberProperty :: forall (s :: Symbol) (r :: [PropertyKey]). (KnownSymbol s, NotElem s r) => KeyNameProxy s -> Text -> Double -> Properties r -> Properties ('PropertyKey s 'TNumber ': r)
- defineIntegerProperty :: forall (s :: Symbol) (r :: [PropertyKey]). (KnownSymbol s, NotElem s r) => KeyNameProxy s -> Text -> Int -> Properties r -> Properties ('PropertyKey s 'TInteger ': r)
- defineStringProperty :: forall (s :: Symbol) (r :: [PropertyKey]). (KnownSymbol s, NotElem s r) => KeyNameProxy s -> Text -> Text -> Properties r -> Properties ('PropertyKey s 'TString ': r)
- defineBooleanProperty :: forall (s :: Symbol) (r :: [PropertyKey]). (KnownSymbol s, NotElem s r) => KeyNameProxy s -> Text -> Bool -> Properties r -> Properties ('PropertyKey s 'TBoolean ': r)
- defineObjectProperty :: forall (s :: Symbol) (r :: [PropertyKey]) a. (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a) => KeyNameProxy s -> Text -> a -> Properties r -> Properties ('PropertyKey s ('TObject a) ': r)
- defineArrayProperty :: forall (s :: Symbol) (r :: [PropertyKey]) a. (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a) => KeyNameProxy s -> Text -> [a] -> Properties r -> Properties ('PropertyKey s ('TArray a) ': r)
- defineEnumProperty :: forall (s :: Symbol) (r :: [PropertyKey]) a. (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a, Eq a, Show a) => KeyNameProxy s -> Text -> [(a, Text)] -> a -> Properties r -> Properties ('PropertyKey s ('TEnum a) ': r)
- definePropertiesProperty :: forall (s :: Symbol) (r :: [PropertyKey]) (childrenProps :: [PropertyKey]). (KnownSymbol s, NotElem s r) => KeyNameProxy s -> Text -> Properties childrenProps -> Properties r -> Properties ('PropertyKey s ('TProperties childrenProps) ': r)
- toDefaultJSON :: forall (r :: [PropertyKey]). Properties r -> [Pair]
- toVSCodeExtensionSchema :: forall (r :: [PropertyKey]). Text -> Properties r -> [Pair]
- usePropertyEither :: forall (s :: Symbol) (k :: PropertyKey) (t :: PropertyType) (r :: [PropertyKey]). HasProperty s k t r => KeyNameProxy s -> Properties r -> Object -> Either String (ToHsType t)
- useProperty :: forall (s :: Symbol) (k :: PropertyKey) (t :: PropertyType) (r :: [PropertyKey]). HasProperty s k t r => KeyNameProxy s -> Properties r -> Object -> ToHsType t
- usePropertyByPathEither :: ParsePropertyPath rs r => KeyNamePath r -> Properties rs -> Object -> Either String (ToHsType (FindByKeyPath r rs))
- usePropertyByPath :: ParsePropertyPath rs r => KeyNamePath r -> Properties rs -> Object -> ToHsType (FindByKeyPath r rs)
- (&) :: a -> (a -> b) -> b

# Documentation

data PropertyType #

Types properties may have

Constructors

TNumber |
TInteger |
TString |
TBoolean |
TObject Type |
TArray Type |
TEnum Type |
TProperties [PropertyKey] | A typed TObject, defined in a recursive manner

type family ToHsType (t :: PropertyType) where ... #

Equations

ToHsType 'TNumber = Double |
ToHsType 'TInteger = Int |
ToHsType 'TString = Text |
ToHsType 'TBoolean = Bool |
ToHsType ('TObject a) = a |
ToHsType ('TArray a) = [a] |
ToHsType ('TEnum a) = a |
ToHsType ('TProperties _1) = Object |

type family NotElem (s :: Symbol) (r :: [PropertyKey]) where ... #

Equations

NotElem s ('PropertyKey s _1 ': _2) = TypeError (('Text "The key \8216" ':<>: 'Text s) ':<>: 'Text "\8217 is already defined") :: Constraint |
NotElem s (_1 ': xs) = NotElem s xs |
NotElem s ('[] :: [PropertyKey]) = () |

data MetaData (t :: PropertyType) where #

Metadata of a property

Constructors

MetaData |
Fields :: forall (t :: PropertyType). (IsTEnum t ~ 'False, IsProperties t ~ 'False) => { defaultValue :: ToHsType t , description :: Text } -> MetaData t
EnumMetaData |
Fields :: forall (t :: PropertyType). IsTEnum t ~ 'True => { defaultValue :: ToHsType t , description :: Text , enumValues :: [ToHsType t] , enumDescriptions :: [Text] } -> MetaData t
PropertiesMetaData |
Fields :: forall (t :: PropertyType) (rs :: [PropertyKey]). t ~ 'TProperties rs => { defaultValue :: ToHsType t , description :: Text , childrenProperties :: Properties rs } -> MetaData t

data PropertyKey #

Used at type level for name-type mapping in `Properties`

Constructors

PropertyKey Symbol PropertyType |

data SPropertyKey (k :: PropertyKey) where #

Singleton type of `PropertyKey`

Constructors

SNumber :: forall (s :: Symbol). SPropertyKey ('PropertyKey s 'TNumber) |
SInteger :: forall (s :: Symbol). SPropertyKey ('PropertyKey s 'TInteger) |
SString :: forall (s :: Symbol). SPropertyKey ('PropertyKey s 'TString) |
SBoolean :: forall (s :: Symbol). SPropertyKey ('PropertyKey s 'TBoolean) |
SObject :: forall a (s :: Symbol). (ToJSON a, FromJSON a) => Proxy a -> SPropertyKey ('PropertyKey s ('TObject a)) |
SArray :: forall a (s :: Symbol). (ToJSON a, FromJSON a) => Proxy a -> SPropertyKey ('PropertyKey s ('TArray a)) |
SEnum :: forall a (s :: Symbol). (ToJSON a, FromJSON a, Eq a, Show a) => Proxy a -> SPropertyKey ('PropertyKey s ('TEnum a)) |
SProperties :: forall (s :: Symbol) (pp :: [PropertyKey]). SPropertyKey ('PropertyKey s ('TProperties pp)) |

data KeyNameProxy (s :: Symbol) #

A proxy type in order to allow overloaded labels as properties' names at the call site

Constructors

KnownSymbol s => KeyNameProxy |

#### Instances

Instances details

(KnownSymbol s', s ~ s') => IsLabel s (KeyNameProxy s') # |
Instance details Defined in Ide.Plugin.Properties Methods fromLabel :: KeyNameProxy s' #

data KeyNamePath (r :: NonEmptyList Symbol) where #

a path to a property in a json object

Constructors

SingleKey :: forall (s :: Symbol). KeyNameProxy s -> KeyNamePath ('NE s) |
ConsKeysPath :: forall (s1 :: Symbol) (ss :: NonEmptyList Symbol). KeyNameProxy s1 -> KeyNamePath ss -> KeyNamePath (s1 ':| ss) |

data Properties (r :: [PropertyKey]) #

`Properties` is a partial implementation of json schema, without supporting union types and validation. In hls, it defines a set of properties used in dedicated configuration of a plugin. A property is an immediate child of the json object in each plugin's "config" section. It was designed to be compatible with vscode's settings UI. Use `emptyProperties` and `useProperty` to create and consume `Properties`.

type HasProperty (s :: Symbol) (k :: PropertyKey) (t :: PropertyType) (r :: [PropertyKey]) = (k ~ 'PropertyKey s t, Elem s r, FindByKeyPath ('NE s) r ~ t, FindByKeyName s r ~ t, KnownSymbol s, FindPropertyMeta s r t) #

In row `r`, there is a `PropertyKey` `k`, which has name `s` and carries haskell type `t`

type HasPropertyByPath (props :: [PropertyKey]) (path :: NonEmptyList Symbol) (t :: PropertyType) = (t ~ FindByKeyPath path props, ParsePropertyPath props path) #

emptyProperties :: Properties ('[] :: [PropertyKey]) #

Creates a `Properties` that defines no property

Useful to start a definitions chain, for example: `properties = emptyProperties & defineStringProperty #exampleString "Description of exampleString" Foo & defineNumberProperty #exampleNumber "Description of exampleNumber" 233`

defineNumberProperty #

Arguments

:: forall (s :: Symbol) (r :: [PropertyKey]). (KnownSymbol s, NotElem s r) |
=> KeyNameProxy s |
-> Text | description
-> Double | default value
-> Properties r |
-> Properties ('PropertyKey s 'TNumber ': r) |

Defines a number property

defineIntegerProperty #

Arguments

:: forall (s :: Symbol) (r :: [PropertyKey]). (KnownSymbol s, NotElem s r) |
=> KeyNameProxy s |
-> Text | description
-> Int | default value
-> Properties r |
-> Properties ('PropertyKey s 'TInteger ': r) |

Defines an integer property

defineStringProperty #

Arguments

:: forall (s :: Symbol) (r :: [PropertyKey]). (KnownSymbol s, NotElem s r) |
=> KeyNameProxy s |
-> Text | description
-> Text | default value
-> Properties r |
-> Properties ('PropertyKey s 'TString ': r) |

Defines a string property

defineBooleanProperty #

Arguments

:: forall (s :: Symbol) (r :: [PropertyKey]). (KnownSymbol s, NotElem s r) |
=> KeyNameProxy s |
-> Text | description
-> Bool | default value
-> Properties r |
-> Properties ('PropertyKey s 'TBoolean ': r) |

Defines a boolean property

defineObjectProperty #

Arguments

:: forall (s :: Symbol) (r :: [PropertyKey]) a. (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a) |
=> KeyNameProxy s |
-> Text | description
-> a | default value
-> Properties r |
-> Properties ('PropertyKey s ('TObject a) ': r) |

Defines an object property

defineArrayProperty #

Arguments

:: forall (s :: Symbol) (r :: [PropertyKey]) a. (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a) |
=> KeyNameProxy s |
-> Text | description
-> [a] | default value
-> Properties r |
-> Properties ('PropertyKey s ('TArray a) ': r) |

Defines an array property

defineEnumProperty #

Arguments

:: forall (s :: Symbol) (r :: [PropertyKey]) a. (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a, Eq a, Show a) |
=> KeyNameProxy s |
-> Text | description
-> [(a, Text)] | valid enum members with each of description
-> a |
-> Properties r |
-> Properties ('PropertyKey s ('TEnum a) ': r) |

Defines an enum property

definePropertiesProperty :: forall (s :: Symbol) (r :: [PropertyKey]) (childrenProps :: [PropertyKey]). (KnownSymbol s, NotElem s r) => KeyNameProxy s -> Text -> Properties childrenProps -> Properties r -> Properties ('PropertyKey s ('TProperties childrenProps) ': r) #

toDefaultJSON :: forall (r :: [PropertyKey]). Properties r -> [Pair] #

Converts a properties definition into kv pairs with default values from `MetaData`

toVSCodeExtensionSchema :: forall (r :: [PropertyKey]). Text -> Properties r -> [Pair] #

Converts a properties definition into kv pairs as vscode schema

usePropertyEither :: forall (s :: Symbol) (k :: PropertyKey) (t :: PropertyType) (r :: [PropertyKey]). HasProperty s k t r => KeyNameProxy s -> Properties r -> Object -> Either String (ToHsType t) #

Given the name of a defined property, generates a JSON parser of `plcConfig`

useProperty :: forall (s :: Symbol) (k :: PropertyKey) (t :: PropertyType) (r :: [PropertyKey]). HasProperty s k t r => KeyNameProxy s -> Properties r -> Object -> ToHsType t #

Like `usePropertyEither` but returns `defaultValue` on parse error

usePropertyByPathEither :: ParsePropertyPath rs r => KeyNamePath r -> Properties rs -> Object -> Either String (ToHsType (FindByKeyPath r rs)) #

usePropertyByPath :: ParsePropertyPath rs r => KeyNamePath r -> Properties rs -> Object -> ToHsType (FindByKeyPath r rs) #

(&) :: a -> (a -> b) -> b infixl 1 #

`&` is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator `$`, which allows `&` to be nested in `$`.

This is a version of ``flip` `id``, where `id` is specialized from `a -> a` to `(a -> b) -> (a -> b)` which by the associativity of `(->)` is `(a -> b) -> a -> b`. flipping this yields `a -> (a -> b) -> b` which is the type signature of `&`

#### Examples

Expand

    >>> 5 & (+1) & show
    "6"

    >>> sqrt $ [1 / n^2 | n <- [1..1000]] & sum & (*6)
    3.1406380562059946

@since base-4.8.0.0