-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added section for other programming languages
- Loading branch information
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "Other Programming Languages", | ||
"position": 4, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "FModel is ported to other programming languages. This section contains links to the documentation and brief descriptions." | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
|
||
# Rust | ||
|
||
Domain modeling, influenced by functional programming principles, aims to represent the business domain in the code accurately. | ||
[Rust](https://www.rust-lang.org/) is ideal thanks to its ownership model and type system, which enforce correctness and reliability - enabling you to eliminate many classes of bugs at compile-time, guarantying memory-safety and thread-safety. | ||
|
||
- You can find the source code for the `fmodel-rust` [here](https://github.com/fraktalio/fmodel-rust) | ||
- Publicly available at [crates.io](https://crates.io/crates/fmodel-rust) and | ||
- [docs.rs](https://docs.rs/fmodel-rust/latest/fmodel_rust/) | ||
|
||
## Decide | ||
|
||
`type DecideFunction<'a, C, S, E> = Box<dyn Fn(&C, &S) -> Vec<E> + 'a + Send + Sync>` | ||
|
||
On a higher level of abstraction, any information system is responsible for handling the intent (`Command`) and based on | ||
the current `State`, produce new facts (`Events`): | ||
|
||
- given the current `State/S` *on the input*, | ||
- when `Command/C` is handled *on the input*, | ||
- expect `Vec` of new `Events/E` to be published/emitted *on the output* | ||
|
||
## Evolve | ||
|
||
`type EvolveFunction<'a, S, E> = Box<dyn Fn(&S, &E) -> S + 'a + Send + Sync>` | ||
|
||
The new state is always evolved out of the current state `S` and the current event `E`: | ||
|
||
- given the current `State/S` *on the input*, | ||
- when `Event/E` is handled *on the input*, | ||
- expect new `State/S` to be published *on the output* | ||
|
||
Two functions are wrapped in a datatype class (algebraic data structure), which is generalized with three generic | ||
parameters: | ||
|
||
```rust | ||
pub struct Decider<'a, C: 'a, S: 'a, E: 'a> { | ||
pub decide: DecideFunction<'a, C, S, E>, | ||
pub evolve: EvolveFunction<'a, S, E>, | ||
pub initial_state: InitialStateFunction<'a, S>, | ||
} | ||
``` | ||
|
||
## Further reading | ||
|
||
[**Read more**](https://docs.rs/fmodel-rust/latest/fmodel_rust/) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# TypeScript | ||
|
||
[TypeScript](https://www.typescriptlang.org/) understands JavaScript and uses type inference to give you great tooling without additional code. | ||
|
||
TypeScript is ideal thanks to its language features and type system, which enforce correctness and reduce the likelihood of bugs. | ||
By modeling the domain accurately, we aim to use the TypeScript transpiler to catch errors early and prevent them from propagating to runtime. | ||
|
||
- You can find the source code for the `fmodel-ts` [here](https://github.com/fraktalio/fmodel-ts) | ||
- Publicly available at [npmjs.com](https://www.npmjs.com/package/@fraktalio/fmodel-ts) | ||
|
||
## Decide | ||
|
||
`(command: C, state: S) => readonly E[]` | ||
|
||
On a higher level of abstraction, any information system is responsible for handling the intent (`Command`) and based on | ||
the current `State`, produce new facts (`Events`): | ||
|
||
- given the current `State/S` *on the input*, | ||
- when `Command/C` is handled *on the input*, | ||
- expect `list` of new `Events/E` to be published/emitted *on the output* | ||
|
||
## Evolve | ||
|
||
`(state: S, event: E) => S` | ||
|
||
The new state is always evolved out of the current state `S` and the current event `E`: | ||
|
||
- given the current `State/S` *on the input*, | ||
- when `Event/E` is handled *on the input*, | ||
- expect new `State/S` to be published *on the output* | ||
|
||
Two functions are wrapped in a datatype class (algebraic data structure), which is generalized with three generic | ||
parameters: | ||
|
||
```typescript | ||
export class Decider<C, S, E> implements IDecider<C, S, E> { | ||
constructor( | ||
readonly decide: (c: C, s: S) => readonly E[], | ||
readonly evolve: (s: S, e: E) => S, | ||
readonly initialState: S | ||
) { | ||
} | ||
} | ||
``` | ||
|
||
## Further reading | ||
|
||
[**Read more**](https://fraktalio.com/fmodel-ts/) |