# Constrained Programming Scratchpad
Created: 2023_07_03 17:28
Tags: [[Technology]]
![[Intentional Programming.excalidraw.svg]]
Based on the actor model:
A function is completely substitutable with content-based addressing. Globally unique and callable across network boundaries. There is a spec file which describes the specification (read prompt) of what the function does, it's expected input & output and how to properly call it.
Functions then have names that allow you to version underneath them (making the function name be a pointer to the content-based address hash)
Therefore, a function is defined as:
```yaml
name: FunctionName
description: "Human readable spec of what the function does"
version: ContentHash
input: TypeScriptType[]
output: Promise<TypeScriptType>
```
It is a bundler! Take this file and output some transformed version of it
Serialize JS objects and such to go over the wire when needed. Functions get turned into this same model that can be callable when passed as a callback. If one server is overloaded it can pass off execution to another computer (maybe there is some heuristic to know when to attempt to do this or not). How do you solve global state? Maybe this framework has to be aware of the global state to work properly. And uses some synchronization mechanism?
I had a small chat with GPT-4 about it and got somewhere with it: https://chat.openai.com/chat/afc2b9c5-3bb7-48a9-998a-fcdd9ffd0b65
Have a sort of IDE that can do some inspection of outputs (source code & runtime behavior) while giving control to the user to build what they want to build, like regenerating prompts & tweaking? I'm not sure about tweaking though because ideally, your spec is well-defined enough that tweaks will not be needed and at worst you would have to regenerate
Would require a specification around how to describe the work to be completed, would want to start with typescript types as inputs, outputs & context (types which may be relevant to completing the task like describing external interfaces). Example:
```ts
// @context
/**
* Describes a single item to be found
**/
type Item = {
label: string;
properties: {
xyz: boolean;
}
}
/**
* Describes the type of the file `xyz.json` located in the `./dist` directory
**/
type Items = Items[];
// @input
type Input = {
id: string;
}
// @output
type Output = Item;
// @prompt
/**
* Write a function which given the @input will find the item in the @output
**/
```
### Example Prompt
> Given `@context`, write a file that takes `@input` type, and outputs `@output` type, as described by `@prompt`. Respond in TypeScript, including a JSDoc description of what each function does.
## References
-