Using UML for Functional Programming

I am looking into using UML to model/design for functional programming. (Bear in mind that I am not talking about the small subset of UML that relates mainly to object oriented programming) I would really appreciate it if anyone knows of an established form for this, or a good example. I would hate to make up my own and then find out that there was already something out there that fits and is in use…

And, yes, I have attempted research on this. But Google seems to have become so “optimized” these days that I can spend hours trying to find something that is off the beaten path only to find everything except what I am looking for…

Thanks in advance.

I found the question interesting and spent some time researching.
Based on that short research I don’t think some UML notation for Functional Programming (FP) exists.


I found three papers that looked promising:

A paper by Yusuf Moosa Motara (published in 2020) claims “It is currently impossible to model functional programs in the same way that UML is used to model object-oriented programs: no analogous graphical notation exists.” (source).

Another paper by Steffen Heinzl and Vitaliy Schreibmann (published in 2018) proposes a new <<Function>> stereotype (source) which IMHO confirms that currently UML does not fully support FP.

A third paper by Marcin Szlenk (published in 2011) demonstrates how UML’s profiles can be used to define a dialect with stereotypes (source). This is the most concrete one I’ve seen, as an example it shows how this Haskell code:

module AStack (Stack, push, pop, top, size) where

data Stack a = Empty | MkStack a (Stack a)

push :: a -> Stack a -> Stack a
push x s = MkStack x s

size :: Stack a -> Int
size s = length (stkToLst s) where
            stkToLst Empty          = []
            stkToLst (MkStack x s)  = x : stkToLst s

pop :: Stack a -> (a, Stack a)
pop (MkStack x s) = (x, s)

top :: Stack a -> a
top (MkStack x s) = x

can be modeled as

┌───────────────────────────────────┐                            ┌┄┄┄┐
│             «Module»              │    ┌──────────────────────╴┊ a ┊
│              AStack               │    │        «UserType»     └┄┄┄┘
├───────────────────────────────────┤    │         + Stack         │
│            «Function»             │    ├─────────────────────────┤
│ + push(x a, s Stack<a>): Stack<a> │╌╌╌›│      «Constructor»      │
│ + size(s Stack<a>): Int           │    │ + Empty()               │
│ + pop(s Stack<a>): (a, Stack<a>)  │    │ + MkStack(:a, Stack<a>) │
│ + top(s Stack<a>): a              │    └─────────────────────────┘
└───────────────────────────────────┘

This 3rd paper also concludes that “It seems that, so far, no work has been done on tailoring UML to model functional programs.

Disclaimer: I am not a researcher nor do I use UML or FP in practice. One of my professors (many years ago) did publish in that area but I’ve never had much use for UML except for documenting high-level architectures and sequences.


May I ask what you’re hoping for? Do you want some graphical notation for documenting key aspects of your solution? Do you want a graphical editor to produce these diagrams? Do you want to program in UML and get the the source code generated for you?

I found that one fairly early in my search. UML can be used for many things outside of OO programming, including processes outside of data processing - but it does not seem like that poster is aware of this.

It is not a matter of not having any idea how, but that I am hoping someone is already familiar with a format for doing it. Personally I am looking at Activities and Swimlanes for my use case. But, as stated previously, if there is already a form/format in use by others I would rather try that first.

Also, also as stated above (I believe I said this?), Google seems to be on rails for searches these days. If it has to do with programming it seems to me to be heavily weighted object oriented based material, despite putting search terms like “functional” in.

@ siebenschlaefer
I am just looking for a solid process to visually represent functional process prior to writing functional code. It doesn’t have to be UML. Right now I am working through a course in Model Based Engineering centered around SYSML to see how well it might serve. I whish to make it a habit to do the design of a functional program in a format independent of the programming language. I strongly believe that such practice leads to better results and less expenditure of resources in the long run.