2 ms·
Interesting article, also very F# specific. A similar approach with type aliases (to be moved to value objects or structs with behaviour aka rich models) in Ru
by ronlobo 7y ago
Interesting article, also very F# specific.
A similar approach with type aliases (to be moved to value objects or structs with behaviour aka rich models) in Rust.
```rust
type Amount = u128;
type MoneySign = Option<Sign>;
type Precision = u8;
type CurrencyIsoCode = &'static str;
type CurrencyName = &'static str;
type Currency = (CurrencyIsoCode, CurrencyName);
type Money = (Amount, MoneySign, Precision, Currency);
type Balance = (Money);
type ExpirationDate = &'static str;
type MoneyWithdrawalError = &'static str;
enum MoneyWithdrawalResult {
Success(Money),
InsufficientFunds(Balance(Money)),
CardExpired(ExpirationDate),
UndisclosedFailure(MoneyWithdrawalError),
}
```