Skip to content

fraktalio/Information-Systems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Heapcon WarmUp MeetUp - 16 October 2025

fmodel

Data & Behaviour = Information (Algebra of the Business)

  • Data (examples/api.kt): Commands, Events, State
  • Behaviour (examples/domain.kt): Exhaustive pattern matching on data

Overview

This project encodes information systems as composable algebraic structures using pure Kotlin functions.

It unifies two classical architectural styles:

  • ๐Ÿ›๏ธ State-stored systems โ€” store current state directly
  • ๐ŸŒ€ Event-sourced systems โ€” store past events and reconstruct state from them

Both are captured under a single algebraic model โ€” the System type.

decide       : Command ร— State โ†’ Sequence<Event>
evolve       : State ร— Event   โ†’ State
initialState : ()              โ†’ State
data class System<Command, State, Event>(
    val decide: (Command, State) -> Sequence<Event>,
    val evolve: (State, Event) -> State,
    val initialState: () -> State
)

Convert between representations easily:

val system: System<C, S, E> = ...

val stateStored: StateStoredSystem<C, S> = system.asStateStoredSystem()
val eventSourced: EventSourcedSystem<C, E> = system.asEventSourcedSystem()

Algebraic View

Concept Mathematical Structure Notes
mapCommand Contravariant Functor Maps input command types
mapEvent Profunctor (dimap) Contravariant in input events, covariant in output
mapState Profunctor (dimap) Contravariant in input state, covariant in output
combine Monoidal Product Combines two systems into a product system
emptySystem Monoidal Identity Represents the โ€œno-opโ€ system (System<Nothing?, Unit, Nothing?>)

๐Ÿ“š Learn More - fmodel.fraktalio.com

domain modeling

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages