In one sentence, I’d say that DNS is a chain-of-trust system for configuring
This is a very rough set of notes taken in 2022 to help engineers understand the logic as well as the nontrivial Haskell concepts (e.g. GHC extensions) embodied in that logic.
It is not an official guide from the Duckling authors, and there are likely at least a few errors.
These notes only cover the core Duckling engine, not any logic specific to a specific Dimension. Most dimensions are relatively straightforward, but some are quite complicated - particularly Time - and these notes do not cover those.
This gist is a collection of all the easy-to-find online resources for using typed python as of 2022/01. I collected these notes for two reasons:
- As an aside in an extensive python-dev typing discussion, Guido mentioned that it would be helpful
- There’s an active but very slow-moving effort to write official python
type system docs in
python/typing
, and I figured having an easy to skim list of the best existing discussions would be handy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dog: | |
def __init__(self, color: str) -> None: | |
self.color = color | |
def __call__(self, command: str) -> None: | |
print("Dog will now " + command) | |
inspect.signature(Dog("brown")) == inspect.signature(Dog) # False | |
inspect.signature(Dog("brown")) == inspect.signature_of_type(Dog) # True |
This gist contains
- A description of some major concerns I have about adding
->
as a legal top-level operator in type expressions. - Discussion of solutions that involve requiring parentheses around callable types.
- Two files of examples of proposed alternative syntax
- First, a comparison of the current syntax to requiring parentheses both around the args list (as we do now) and around the entire type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A quick example to illustrate the two syntaxes | |
def f(x: str, y: int) -> bool: ... | |
f: ((str, int) -> bool) # full parentheses syntax | |
f: (str, int) -> bool # args only parentheses | |
# Now, some samples from typeshed (I abbreviated a few args lists so that it's easier to find the relevant part) |
- We can't naively union a callable type with another type:
union_of_callables: (int) -> str | (bool) -> str # Syntax error!
# Needs extra parens; Not intuitive or user-friendly.
union_of_callable2: ((int) -> str) | ((bool) -> str)
# Simpler and can be easily split into multiple lines, as Никита mentioned.