See archived version with outlinks here.
As of May 26, 2023, there is no standard modeling language for pure functional programming, but there are alternatives:
1. UML
UML has traditionally been associated with object-oriented programming (OOP), mostly because of its historical roots1, 2, but one can certainly attempt to use it for different programming paradigms (or for something other than modeling software, for that matter, such as use-case diagrams, ontology engineering, manufacture and other systems & processes, etc.).
With that said, there don’t seem to be many examples around for this use case. A noteworthy few:
- https://softwareengineering.stackexchange.com/a/302840/278679
- https://stackoverflow.com/a/49955879/1498178
- https://stackoverflow.com/a/44627260/1498178
- https://stackoverflow.com/a/2457948/1498178
The answers above mention that there are UML diagram types other than class diagrams, whose use would benefit any program, independent of paradigm. See 1 and the Modeling applications of UML using various diagrams section of the Applications of UML wikipedia page, along with a diagram:
source
[1]: UML Diagrams: History, Types, Characteristics, Versions, Tools
[2]: https://stackoverflow.com/a/27861475/1498178
1.1 Statecharts
From the Statecharts: a visual formalism for complex systems paper:
[statecharts] extend conventional state-transition diagrams with essentially three elements, dealing, respectively, with the notions of hierarchy, concurrency and communication. These transform the language of state diagrams into a highly structured and economical
description language.
If the program doesn’t deal with state, then this is not very useful but it seems to be a noteworthy tool otherwise.
More info and discussions:
- statecharts.dev
- State diagram – Wikipedia
- Finite-State Machines, Part 1: Modeling with Haskell Data Types | Oskar Wickström
- state machine – How can I Implement Statecharts in Haskell? – Stack Overflow
- haskellers thoughts on statecharts : haskell (reddit)
2. Diagrams
2.1 Wiring diagram
From Seven Sketches in Compositionality: An Invitation to Applied Category Theory, section 2.2.2 Introducing wiring diagrams:
Wiring diagrams are visual representations for building new relationships from old.
Examples:
2.2 String diagram
Seven Sketches in Compositionality: An Invitation to Applied Category Theory mentions string diagrams, but they seem to be different from wiring diagrams. From the paper Category Theory Using String Diagrams:
String diagrams are a graphical formalism for working in category theory, providing a convenient tool for describing morphisms within bicategories [B ́enabou, 1967], some background on string diagrams can be found in [Street, 1995].
2.3 Data flow diagrams
This section expands on this answer.
2.3.1 “Henderson diagram”
“These show how individual functions are “plugged together”“. From section 3.5.2 Infinite Streams of SICP:
2.3.2 Diagrams used in the Arrows documentation
class Arrow a where arr :: (b -> c) -> a b c -- Each function may be treated as a computation.
(>>>) :: a b c -> a c d -> a b d -- Computations may be composed, by -- connecting the output of the first -- to the input of the second.
first :: a b c -> a (b,d) (c,d) -- A computation may be applied to part -- of the input, with the rest copied -- through to the output.
2.4 Hasse diagram (wikipedia)
“Category theory is all about organizing and layering structures“3 so Hasse diagrams may be useful. A UML class diagram is “a form of Hasse diagram“, so it can be used in a more general sense to convey dependency relations.
[3] Seven Sketches in Compositionality: An Invitation to Applied Category Theory, section
“1.1.2 Ordering systems”
2.5 Commutative diagram (wikipedia)
These can be used to describe how functions and structures interact with each other; however, they rather define invariants/laws than behaviour.
Examples:
-
User:Michiexile/MATH198/Lecture 7 article in the Haskell Wiki shows diagrams and their implementation in Haskell.
-
category theory:
- Seven Sketches in Compositionality: An Invitation to Applied Category Theory
- Category Theory Using String Diagrams
3. Formal methods
3.1 Universal Systems Language (USL) (proprietary?)
Universal systems language (USL) is a systems modeling language and formal method for the specification and design of software and other complex systems. It was designed by Margaret Hamilton based on her experiences writing flight software for the Apollo program. The language is implemented through the 001 Tool Suite software by Hamilton Technologies, Inc.
See articles on Hamilton Technologies, Inc.’s homepage.
3.2 TLA+
TLA+ is a formal specification language developed by Leslie Lamport. It is used for designing, modeling, documentation, and verification of programs, especially concurrent systems and distributed systems.
It felt prudent to mention TLA+ here as well.
- (2) Embedding TLA+ into Haskell : haskellquestions
- visualization – TLA+ How to visualize the state graph – Stack Overflow
- Leslie Lamport: TLA in Pictures
- Leslie Lamport: The TLA+ Toolbox
4. Tools
4.1 ghc-vis
Similar to Python Tutor,
ghc-vis
is a tool to visualize live Haskell data structures in GHCi. Evaluation is not forced and you can interact with the visualized data structures. This allows seeing Haskell’s lazy evaluation and sharing in action
4.2 Visual Haskell
This thesis presents and justifies a framework for programming real-time signal processing systems. The framework extends the existing “block-diagram” programming model; it has three components: a very high-level textual language, a visual language, and the dataflow process network model of computation.
From section 4.2 An introduction to Visual Haskell:
4.3 Viskell (tool; last commit: 2017)
Viskell is an experimental visual programming environment for a typed (Haskell-like) functional programming language. This project is exploring the possibilities and challenges of interactive visual programming in combination with the strengths and weaknesses of functional languages.
4.4 graphmod
Haskell package
Present the module dependencies of a program as a “dot” graph.
4.5 HOPS: The Higher Object Programming System
HOPS is a graphically interactive program development and program transformation system based on term graphs.
Seems unmaintained, but looked interesting.
See more images / animations here.
Other interesting resources:
-
“Functional modeling methods”” on the Function model wikipedia page
-
DRAKON visual language: “DRAKON is a visual language for specifications from the Russian space program.“
-
Papers by Yusuf Moosa Motara:
- A “UML” equivalent for functional
programming (see companion video) - A structural modeling notation for the typed functional paradigm | Semantic Scholar
- High-Level Modelling for Typed Functional Programming | SpringerLink
- A “UML” equivalent for functional