diff --git a/docs/other/_category_.json b/docs/other/_category_.json new file mode 100644 index 0000000..882f8f0 --- /dev/null +++ b/docs/other/_category_.json @@ -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." + } +} diff --git a/docs/other/rust.md b/docs/other/rust.md new file mode 100644 index 0000000..823eded --- /dev/null +++ b/docs/other/rust.md @@ -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 Vec + '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 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/) \ No newline at end of file diff --git a/docs/other/type-script.md b/docs/other/type-script.md new file mode 100644 index 0000000..45512a8 --- /dev/null +++ b/docs/other/type-script.md @@ -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 implements IDecider { + 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/) \ No newline at end of file