https://github.com/cdiggins/peacock
A Functional UI Library written in C#
https://github.com/cdiggins/peacock
Last synced: 8 months ago
JSON representation
A Functional UI Library written in C#
- Host: GitHub
- URL: https://github.com/cdiggins/peacock
- Owner: cdiggins
- License: mit
- Created: 2022-01-17T19:29:51.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-21T20:25:11.000Z (almost 4 years ago)
- Last Synced: 2025-01-09T07:31:44.751Z (about 1 year ago)
- Language: C#
- Size: 956 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Peacock
Peacock is a pure functional UI library written in C#.
It is being developed to validate the hypothesis that pure functional programming
is a valid approach for building an entire UI component library from the ground up.
The current implementation is built on top of WPF, but it is done so using a thin layer,
that in theory can be easily ported to different platforms (e.g., Unity, HTML, et.)
# Inspiration
The Elm programming language is a big inspiration for Peacock, as are many of the UI
frameworks and best practices being developed by the JavaScript community.
# How does it work
## Control and IControl
Central to Peack is the `IControl` interface, and the generic `Control` class.
A control is parameterized on a class derived from `IView` which represents
the current view state. A view the underlying data model
plus some styling and layout information).
A control also recieves in its constructor two functions:
1. How to render (draw) that particular state type to a canvas
2. A function for converting the state type to child-controls
3. Optionally: zero or more behaviors
## IBehavior
A Behavior is a class that holds its own state object and can provide additional drawing logic for a control,
can transform its state object in response to input events, and can aggregate proposed changes to the views.
## IUpdates
The `IUpdates` class aggregates a set of proposed changes to all views managed by a control.
These changes are managed as a list of functions associated with a particular view ID.
# A Platonic C# Library
Peacock is being written as a *Platonic* C# library. This means that it
is designed to be compliant with the [Plato Language](https://github.com/cdiggins/plato)
and compatible with the Plato tools (optimizer, translators).
Peacock is a key part of validating the design and implementation of Plato as a
general purpose programming language.
# Peacock in Action
To validate the Peacock language I am building a visual programming language editor called
Bohr.