r/functionalprogramming • • Aug 29 '25

Books Functional Design and Architecture on sale (manning sale)

26 Upvotes

Hey! I just discovered by chance that manning.com has a sale for Labor Day going on. They have, e.g., Functional Design and Architecture and ofc. much more.
Thought this might be interesting to some!


r/functionalprogramming • • Jun 14 '25

Question When people say monads encode a context, what do they mean that is more than a data structure?

26 Upvotes

I think I've gotton a pretty good grasp of using monads by now. But I dont get what people mean when they call it a context. How are they more than data structures?

One idea that immediately comes to mind is IO and purity. But if we take for example, Maybe Int, Just 3 >>= \x -> return $ show x will reliably produce Just "3". So it feels like defining monads interms of purity is restrictive? Or is my idea of purity is incorrect?

I have been thinking of them as items in wrapped in a gift box as used in learn you as haskell and a few other resources, but I see people explicitly condemming that mental model as inadequate. So what am I missing?

I guess a concrete question will be what can I do with Maybe as monads that can not be approximated by maybe as Applicatives? I feel like I am asking what can clay do that bricks cant or something like that but it feels so incorrect on my head.

f = (*3)
Just 3 >>= \x -> return f x
Just 3 <*> Just f

And what are side effects? I feel like I get what is meant by this in terms of the State monad and the IO monad. But I cant point to it in code. (I wrote a desugared state monad snippet hoping I could find some concrete question to ask. I didnt but maybe someone can find it useful for illustrating some idea.). But more importantly, what are side effects when it comes to the Maybe monad or the List monad?


r/functionalprogramming • • Apr 15 '25

λ Calculus Symbolverse: lambda calculus compiler, type inference, and evaluator in less than 100 LOC

26 Upvotes

introduction

In the Symbolverse term rewriting framework, functional programming concepts are encoded and executed directly through rule-based symbolic transformation. This post showcases how core ideas from lambda calculus, combinatory logic, and type theory can be seamlessly expressed and operationalized using Symbolverse's declarative rewrite rules. We walk through the construction of a pipeline that compiles lambda calculus expressions into SKI combinator form, performs type inference using a Hilbert-style proof system, and evaluates SKI terms, all implemented purely as rewriting systems. These components demonstrate how Symbolverse can model foundational aspects of computation, logic, and semantics in a minimal yet expressive way.

lambda calculus to SKI compiler

Lambda calculus is a formal system in mathematical logic and computer science for expressing computation based on function abstraction and application. It uses variable binding and substitution to define functions and apply them to arguments. The core components are variables, function definitions (lambda abstractions, e.g., λx.x), and function applications (e.g., (λx.x)y). Lambda calculus serves as a foundation for functional programming languages and provides a framework for studying computation, recursion, and the equivalence of algorithms. Its simplicity and expressiveness make it a cornerstone of theoretical computer science.

The SKI calculus is a foundational system in combinatory logic that eliminates the need for variables by expressing all computations through three basic combinators: S, K, and I. The SKI calculus can be viewed through two complementary lenses: as a computational system and as a logical framework. In its computational interpretation, SKI calculus operates as a minimalist functional evaluator, where the combinators S, K, and I serve as function transformers that enable the construction and reduction of expressions without variables, forming the core of combinatory logic. Conversely, from a logical standpoint, SKI calculus aligns with a Hilbert-style inference system, where S, K, and I are treated not as functions but as axiom schemes or inference rules. In this context, the application of combinators mirrors the process of type inference in logic or proof construction: for instance, the types of S, K, and I correspond to specific theorems in implicational logic, and their application mimics modus ponens. This duality reveals a connection between computation and logic, embodying the Curry-Howard correspondence, where evaluating a term parallels constructing a proof.

Converting lambda calculus expressions to SKI combinator calculus involves eliminating variables by expressing functions solely in terms of the combinators S, K, and I. This process systematically replaces abstractions and applications using transformation rules, such as translating λx.x to I, λx.E (when x is not free in E) to K E, and λx.(E1 E2) to S (λx.E1) (λx.E2). This allows computation to be represented without variable binding.

(
    REWRITE
    
    /entry point/
    (RULE (VAR A) (READ (\lcToSki \A)) (WRITE (compilingToSki A)))
    
    /LC to SKI compiler/
    (RULE (VAR x) (READ (lmbd x x)) (WRITE I))
    (RULE (VAR x E1 E2) (READ (lmbd x (E1 E2))) (WRITE ((S (lmbd x E1)) (lmbd x E2))))
    (RULE (VAR x y) (READ (lmbd x y)) (WRITE (K y)))
    
    /exit point/
    (RULE (VAR A) (READ (compilingToSki A)) (WRITE \A))
)

type inference

The Hilbert-style proof system is a formal deductive framework used in mathematical logic and proof theory. It is named after David Hilbert, who pioneered formal approaches to mathematics in the early 20th century. This system is designed to formalize reasoning by providing a small set of axioms and inference rules that allow the derivation of theorems. In its essence, the Hilbert-style proof system is minimalistic, relying on a few foundational logical axioms and a single or limited number of inference rules, such as modus ponens (if A and A -> B are true, then B is true).

Hilbert-style proof systems can be applied to type checking in programming by leveraging their formal structure to verify the correctness of type assignments in a program. In type theory, types can be seen as logical propositions, and well-typed programs correspond to proofs of these propositions. By encoding typing rules as axioms and inference rules within a Hilbert-style framework, the process of type checking becomes equivalent to constructing a formal proof that a given program adheres to its type specification. While this approach is conceptually elegant, it can be inefficient for practical programming languages due to the system’s minimalistic nature, requiring explicit proofs for even simple derivations. However, it provides a foundational theoretical basis for understanding type systems and their connection to logic, particularly in frameworks like the Curry-Howard correspondence, which bridges formal logic and type theory.

(
    REWRITE
    
    /entry point/
    (RULE (VAR A) (READ (\check \A)) (WRITE (proofChecking A)))
    
    /constant types/
    (
        RULE
        (VAR A)
        (READ (CONST A))
        (WRITE (typed (const A)))
    )
    (
        RULE
        (VAR A B)
        (READ (IMPL (typed A) (typed B)))
        (WRITE (typed (impl A B)))
    )
    
    /axioms/
    (
        RULE
        (VAR A B)
        (READ I)
        (WRITE (typed (impl A A)))
    )
    (
        RULE
        (VAR A B)
        (READ K)
        (WRITE (typed (impl A (impl B A))))
    )
    (
        RULE
        (VAR A B C)
        (READ S)
        (WRITE (typed (impl (impl A (impl B C)) (impl (impl A B) (impl A C)))))
    )
    
    /modus ponens/
    (
        RULE
        (VAR A B)
        (
            READ
            (
                (typed (impl A B))
                (typed A)
            )
        )
        (
            WRITE
            (typed B)
        )
    )
    
    /exit point/
    (RULE (VAR A) (READ (proofChecking (typed A))) (WRITE \A))
    (RULE (VAR A) (READ (proofChecking A)) (WRITE \"Typing error"))
)

SKI calculus interpreter

SKI calculus is a combinatory logic system used in mathematical logic and computer science to model computation without the need for variables. It uses three basic combinators: S, K, and I. The K combinator (Kxy = x) discards its second argument, the I combinator (Ix = x) returns its argument, and the S combinator (Sxyz = xz(yz)) applies its first argument to its third argument and the result of applying the second argument to the third. Through combinations of these three primitives, any computation can be encoded, making SKI calculus a foundation for understanding computation theory.

(
    REWRITE
    
    /entry point/
    (RULE (VAR A) (READ (\interpretSki \A)) (WRITE (interpretingSki A)))
    
    /combinators/
    (RULE (VAR X) (READ (I X)) (WRITE X))
    (RULE (VAR X Y) (READ ((K X) Y)) (WRITE X))
    (RULE (VAR X Y Z) (READ (((S X) Y) Z)) (WRITE ((X Z) (Y Z))))
    
    /exit point/
    (RULE (VAR A) (READ (interpretingSki A)) (WRITE \A))
)

conclusion

By embedding the principles of lambda calculus, combinatory logic, and Hilbert-style proof systems into Symbolverse, we’ve created a compact yet powerful symbolic framework that mirrors key elements of functional programming and formal logic. The LC-to-SKI compiler, type inference engine, and SKI evaluator together highlight the expressive potential of symbolic rewriting to capture the essence of computation, from function abstraction to proof construction. This approach underscores how Symbolverse can serve as both an experimental playground for language design and a practical toolkit for building interpreters, compilers, and reasoning systems using the language of transformation itself.

If you want to explore these examples in online playground, please follow this link.


r/functionalprogramming • • Jan 21 '25

FP Better software design with domain modeling by Eric Normand

Thumbnail
adabeat.com
26 Upvotes

r/functionalprogramming • • Jul 28 '24

Question Type theory and its consequences

26 Upvotes

Hi. Maybe this post doesn't fit this subreddit (even though FP and Type Theory are connected), but I think it's a good place to start.

I want to dive into type theory to improve my understanding of how programming works. Thus, I have a couple of questions:

  1. Does knowing type theory help you write better code?

  2. I work with Python and have some experience in JS and C, but I want to learn Rust. Does learning and practicing type theory help me write better code in Python and Rust? (I picked dynamic and static languages in this question to compare responses.)

  3. Could someone please give a list of good books, courses, and videos on how to learn and use type theory in daily programming? (From beginner to advanced level)

Thank you.


r/functionalprogramming • • Jun 02 '24

Question Are there any technical benefits of point free programming?

26 Upvotes

I usually think of writing point free functions as a way to keep thinking conceptually about a program as the combination of smaller functions. There are definitely situations where it can make code more readable and times where it makes things more complicated.

Lately I've been wondering though if there's any situation where point free functions would offer any significant technical advantage or disadvantage?


r/functionalprogramming • • Jan 19 '24

Gleam Gleam's New Interactive Language Tour

Thumbnail
gleam.run
26 Upvotes

r/functionalprogramming • • Jul 22 '23

λ Calculus Visual Lambda Calculus (playable in browser)

Thumbnail
bntr.itch.io
26 Upvotes

r/functionalprogramming • • Mar 18 '23

OO and FP FP and OOP are close siblings (using OOP to teach Currying) | The Upside-Down Trees

Thumbnail
blog.mhashim6.me
26 Upvotes

r/functionalprogramming • • May 23 '22

FP Flix – Safe, reliable, concise, and functional-first programming language

Thumbnail
flix.dev
26 Upvotes

r/functionalprogramming • • Apr 15 '22

Question Real world examples of functional JavaScript?

26 Upvotes

I'm trying to learn to write more functional (FP) JavaScript. But I'm tired of the million lazy bloggers that clutter up my search efforts, that regurgitate the same low-hanging fruit, you know, an adder function, a factorial function, mentioning how FP makes it "easy to reason about your code".

I'm basically tired of blogs and tutorials that seem to know as much about FP as I do.

Anyone know some GitHub repositories where I can see FP JavaScript applied in real world apps? I want to see how they manage user input, how they pass around database connections elegantly, etc.


r/functionalprogramming • • Oct 19 '21

FP Function pipelines: Building functional programming into PostgreSQL using custom operators

Thumbnail
blog.timescale.com
26 Upvotes

r/functionalprogramming • • Jul 30 '21

Erlang 5 Banks and FinTechs Using Erlang or Elixir

26 Upvotes

We have taken a look and some of the successful companies in financial services leveraging the power of the BEAM to power their tech systems.

Find out who is on the list on our blog > https://www.erlang-solutions.com/blog/5-erlang-and-elixir-use-cases-in-fintech/


r/functionalprogramming • • Jun 06 '21

C++ FTXUI - C++ Functional Terminal User Interface

Thumbnail
github.com
26 Upvotes

r/functionalprogramming • • Mar 10 '21

Lisp Software Design for Flexibility - How to Avoid Programming Yourself into a Corner

Thumbnail
mitpress.mit.edu
26 Upvotes

r/functionalprogramming • • Jan 28 '21

Elm Safe dead code removal in a pure functional language

Thumbnail
jfmengels.net
26 Upvotes

r/functionalprogramming • • Nov 13 '20

Question Where do I start learning and what do I learn?

26 Upvotes

Hello,

I’m fresh to computer science. I have only taken one introductory course to programming and they taught us JavaScript, but not enough for us to write a program on our own, just the bare bones basics.

I did some research in types of languages and got fascinated with the idea that a functional programming language is very abstract and high level and supposedly better than OOP type languages.

My background is in humanities. I have barely any mathematics under my belt.

I’m going back to university soon for Computer Science but I can’t find any functional programming concentration and I did some reading here that stated learning OOP type languages first would make It much more difficult to learn a FP language later, but not if I learn FP and then an OOP.

Where should I start from the very basics until university level and what should I expect in terms of self-learning vs guided learning ?


r/functionalprogramming • • Aug 30 '20

Intro to FP Inventing Monads

Thumbnail
stopa.io
26 Upvotes

r/functionalprogramming • • Jul 21 '20

Elm Elm might be the easiest way to get introduced to FP or programming in general

26 Upvotes

Last weekend I stumbled upon Elm by chance.

Having tried Haskell and being a fan of functional programming I was immediately hooked because frontend development has been something I had been struggling with for a lot of time.

I know there's been some drama in the Elm community and some people complain that it doesn't implement advanced features like haskell's typeclasses. But, I can definitely see it become the first choice when trying to learn FP or even programming in general.

Unlike haskell, not only is it easy to setup with VS Code, but you immediately can see the results of your work in an interactive website. For someone's who's new to programming or even someone who's learning FP, immediately being able to see your results in the browser and playing around with the buttons or interactive fields is quite the experience. Also, the compiler error messages are the best I've ever seen.

At the moment it's the single best experience I've had for easily creating fronted applications from which I can then call my backend API endpoints.

So, this might be just my two cents, but I wish Elm was considered a choice when people ask which language to learn programming with. An FP first approach to learning programming might a realistic possibility with Elm in my opinion.


r/functionalprogramming • • Jul 07 '20

Intro to FP I launched a new functional programming channel with a deep dive on functions

Thumbnail
youtu.be
26 Upvotes

r/functionalprogramming • • Jun 29 '20

Question ELI5: what is delimited continuation?

26 Upvotes

r/functionalprogramming • • Jun 16 '20

FP Functional Programming for Array-Based Parallelism

Thumbnail
infoq.com
26 Upvotes

r/functionalprogramming • • May 25 '20

Intro to FP ADTs in Practice. How to model a Web API using Algebraic Data Types

Thumbnail
last-ent.com
26 Upvotes

r/functionalprogramming • • May 13 '20

OO and FP Life After Business Objects - Confessions of an OOP Veteran

Thumbnail
youtu.be
26 Upvotes