Skip to content

Commit

Permalink
added section for other programming languages
Browse files Browse the repository at this point in the history
  • Loading branch information
idugalic committed Dec 3, 2023
1 parent 10ebf91 commit 188093b
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/other/_category_.json
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."
}
}
49 changes: 49 additions & 0 deletions docs/other/rust.md
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/)
52 changes: 52 additions & 0 deletions docs/other/type-script.md
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/)

0 comments on commit 188093b

Please sign in to comment.