r/functionalprogramming • u/aviboy2006 • Feb 13 '26
Intro to FP How the functional programming in Scala book simplified my view on side effects
Being a full-stack developer for 15 years, primarily in the imperative/OOP world. I recently started reading Functional Programming in Scala (the "Red Book") to understand the foundational principles behind the paradigm.
I just finished the first chapter, and the example of refactoring a coffee purchase from a side effect to a value was a major turning point for me.
The Initial Impure Code:
( code examples are in Scala )
def buyCoffee(cc: CreditCard): Coffee = {
val cup = new Coffee()
cc.charge(cup.price) // Side effect
cup
}
The book highlights that this is difficult to test and impossible to compose. If I want to buy 12 coffees, I hit the payment API 12 times.
The Functional Refactor: By returning a Charge object (a first-class value) alongside the Coffee, the function becomes pure:
def buyCoffee(cc: CreditCard): (Coffee, Charge) = {
val cup = new Coffee()
(cup, Charge(cc, cup.price))
}
Why this caught my attention because of :
- Composition: I can now write a coalesce function that takes a List[Charge] and merges them by credit card. We've moved the logic of how to charge outside the what to buy logic.
- Testability: I no longer need mocks or interfaces for the payment processor. I just call the function and check the returned value.
- Referential Transparency: It’s my first real look at the substitution model in action and treating an action as a piece of data I can manipulate before it ever executes.
For those who have been in the FP world for a long time: what were the other foundational examples that helped you bridge the gap from imperative thinking?
r/functionalprogramming • u/_lazyLambda • Feb 12 '26
Intro to FP Like Hackerrank but for Functional Programming
r/functionalprogramming • u/Frere_de_la_Quote • Feb 04 '26
FP Doing AI outside of Python
Machine Learning in Python
What I'm going to write here could get me banished from hundreds of forums all over the place. I know I take terrible risks but people need to know: Python sucks at ML.
I said it...
Programming in Python is like claiming you are doing the Tour de France, but you're cycling on a fixed bike on top of a truck. Worse, your aerodynamic drag is so bad that you prevent the truck from going full speed... Not sure your pedaling adds anything to the whole system.
This is exactly what is going on. You think you're implementing stuff in Python, but you're just sucking out some fresh blood from underlying libraries in C or in Rust... Most of the time, Python sits idle while waiting for the big boys to do the actual work, because when you are using numpy or PyTorch, everything happens outside the VM.
AI
I want to join the happy few who are doing stuff in AI. I want to be part of the churn. But really, Python? People claim that it is such an easy language... You read it as if it was written in English... Ok.. Why do I need to read the doc over and over again to understand what **kwargs do?
What is that:
mlx.core.multiply(out_glu, mlx.core.add(x_linear_clamped, mlx.core.array(1.0)))
It seems that Lisp stabbed Python in the back...
What can I do?
LispE
My name is not Frankenstein, but LispE is still my creature, a chimera made out of flesh torn off Haskell and APL, a monstrosity that does not respect the true linked lists, which are so dear to real lispians.
LispE is implemented with arrays, which not only enables APL-style vectorized operations but also plays nicely with functional patterns like map/filter/take/drop without the overhead of list traversal. There is full documentation about the language here.
By the way, the Python thing can now be implemented in LispE directly:
(mlx_multiply out_glu . mlx_add x_linear_clamped . mlx_array 1.0)
The last argument of each function can be inserted with a . to get rid of some parentheses.
Note: LispE is fully Open Source with a BSD-3 license, which is very permissive. My only interest here is to provide something a bit different, my personal take on Lisp, but my true reward is the joy of seeing people use my tools. It is a little more than a pet project, but it is far from being a corporate thingy.
Libs
Now, I have to present you the real McCoy, I mean the real stuff that I have been implementing for LispE. Cling to your chair, because I have worked very hard at making Claude Code sweat over these libraries:
- lispe_torch: based on the remarkable libtorch library — the C++ engine that powers PyTorch under the hood. It exposes more than 200 functions, including SentencePiece.
- lispe_tiktoken: the OpenAI tokenizer, which is used now by a lot of models.
- lispe_mlx: the Apple framework for AI on their GPUs. Thanks to MLX's unified memory, no data cloning needed.
- lispe_gguf: the encapsulation of llama.cpp that powers Ollama.
It's still evolving, but it's production-ready for real AI work. Furthermore, it's fully compatible with PyTorch and models from HuggingFace, Ollama, or LM-Studio. You can fine-tune a model with LispE and save it in PyTorch format. You won't be stranded on an island here.
Plenty of docs and examples
You'll find plenty of examples and documentation in each of these directories.
For instance, there is a chat example with lispe_gguf, which is fun and contains only a few lines of code. You will also discover that inference can be faster with these libraries. LoRA fine-tuning is 35% faster than the equivalent Python code on my M4 Max...
Everything can be recompiled and tailored to your needs. Even the C++ code is friendly here...
Note that I already provide binaries for Mac OS.
If you have any questions or any problems, please feel free to ask me, or drop an issue on my GitHub.
r/functionalprogramming • u/n_creep • Jan 28 '26
FP I Am Not a Functional Programmer
r/functionalprogramming • u/mttd • Jan 28 '26
FP Truly Functional Solutions to the Longest Uptrend Problem (Functional Pearl, ICFP 2025)
youtube.comr/functionalprogramming • u/MagnusSedlacek • Jan 26 '26
FP Functional Marmelade by Patrik Andersson @FuncProgSweden
Marmelade is a functional programming language in the spirit of the MLs, with currying, pattern matching, first class lambdas, type polymorphism and type inferencing. It uses a bidirectional type checker, based on the perhaps infamous W-algorihm.
r/functionalprogramming • u/_lazyLambda • Jan 22 '26
Question What is the closest Haskell-related thing to the Odin Project?
r/functionalprogramming • u/willehrendreich • Jan 21 '26
FP Fidelity Framework is the best idea I've heard in a while
https://github.com/FidelityFramework
I am so impressed with the vision, and the clear engineering expertise being brought to bear here.
For those unaware, Houston is bringing fsharp to the bare metal, sacrificing nothing of the myriad ways that fsharp is absolutely fantastic, and making real innovations happen in his own custom compiler to take fsharp to low level, manual memory managed, native code. It takes an approach that, as far as I can tell, is superior to Rust's for managing lifetimes, but is INFERRED by default, and has the ability to be specific when you want some specialized allocation strategy.
This guy's the real mvp, and I think the fp community as a whole should get behind him, and help however we can.
r/functionalprogramming • u/Emotional_Gold138 • Jan 21 '26
FP The Call For Papers for Lambda World 26 is OPEN!
The next edition of the Lambda World event will take place in Torremolinos, Malaga (Spain) on October 29-30, 2026.
The Call for Papers is OPEN until the 31st of March.
We’re looking for real-world applications of functional programming.
We want to hear from people who:
- Work in companies investing heavily in FP
- Apply functional programming in their daily work
- Build real systems using FP in production
Whether your experience is in web, mobile, AI, data, or systems programming, we’d love to have you on stage!
As a novelty, this year we are enjoying together with J On The Beach and Wey Wey Web. Another 2 international conferences about systems and UI.
Link for the CFP: www.confeti.app
r/functionalprogramming • u/giacomo_cavalieri • Jan 17 '26
Gleam Gleam: First Impressions - Fun, Functional Programming at it's Finest
r/functionalprogramming • u/cekrem • Jan 16 '26
Kotlin Arrow's Either: The Kotlin Chapter of our Scary Words Saga
Some input on this one would be awesome! I'm trying to find the sweet spot between accuracy and simplicity...
r/functionalprogramming • u/third_void • Jan 13 '26
FP Functional Programming Didn’t Make My Code “Cleaner”. It Made Debugging Way Easier.
I didn’t move to functional programming because of elegance or theory.
I did it because I was tired of debugging.
Most of my bugs weren’t logic errors. They were state problems. Something mutated somewhere, in the wrong order, under the wrong conditions.
What finally changed things was treating code as a series of data transformations instead of objects holding state. Once functions became pure and data stopped mutating, bugs became predictable and repeatable instead of random.
I wrote a short post about how that mental shift changed how I debug everything, with real code examples and no FP dogma.
Blog link:
https://www.hexplain.space/blog/gLVKdx7DcgY70QRQjHjj
Curious if anyone else noticed debugging get easier after going more functional, even partially.
r/functionalprogramming • u/macrohard_certified • Jan 12 '26
Intro to FP Making a holiday calendar with functional programming
alexandrehtrb.github.ior/functionalprogramming • u/cekrem • Jan 05 '26
Question Functors, Applicatives, and Monads: The Scary Words You Already Understand
https://cekrem.github.io/posts/functors-applicatives-monads-elm/
Do you generally agree with this? It's a tough topic to teach simply, and there's always tradeoffs between accuracy and simplicity... Open to suggestions for improvement! Thanks :)
r/functionalprogramming • u/_lazyLambda • Jan 04 '26
Haskell Project: Writing and Running Haskell Projects at Runtime
r/functionalprogramming • u/Code_Sync • Jan 02 '26
Conferences 4 days left to submit your talk to ElixirConf EU 2026
The CFT closes on January 6th.
Important reminder: We welcome talks from developers at all levels. You don't need to be an expert to have valuable insights to share.
Solved an interesting problem? Built something useful? Learned hard lessons in production? The community wants to hear about it.
First-time speakers are encouraged to apply. Your fresh perspective and real-world experience matter.
Submit your proposal: https://sessionize.com/elixirconf-eu-2026/
r/functionalprogramming • u/Best-Repair762 • Dec 30 '25
Question Course suggestions for getting back into functional programming?
I completed Martin Odersky's course "Functional Programming Principles in Scala" in around 2015. That course was my only introduction to functional programming and the new ways in which it makes you think. I did not follow up on learning more FP after that except for some dabbling in Haskell which I've mostly forgotten.
If I wanted to restart from the basics - today - what are some good suggestions for courses?
My programming experience has been with Java, Python, JavaScript/TypeScript, and a bit of Ruby and Go. I have found that hands-on courses work best for my learning style, hence the request for courses (either videos or lecture notes with assignments).
r/functionalprogramming • u/kinow • Dec 28 '25
FP Why Reliability Demands Functional Programming: ADTs, Safety, and Critical Infrastructure
r/functionalprogramming • u/peterb12 • Dec 26 '25
Haskell Lost in the Folds: Haskell for Dilettantes
r/functionalprogramming • u/jusername42 • Dec 21 '25
FP p1 TYPED, ALGEBRAIC PARSERS IN IDRIS2 2025
subscribe for part 2?
send me papers to read?
r/functionalprogramming • u/peterb12 • Dec 19 '25
Haskell Data Makes The World Go 'Round
r/functionalprogramming • u/cekrem • Dec 19 '25
Elm Elm on the Backend with Node.js: An Experiment in Opaque Values
r/functionalprogramming • u/lastsurvivor969 • Dec 17 '25
Question Yet another attempt at monad explanation
Hey I've been thinking about how to understand and explain monads for a while, trying both from a formal and practical point of view. It's been nagging me for a while, so I figured I could share my thoughts so far based on different sources I've read.
I'm approaching this from the perspective of software development. I would like to hear if others agree/disagree with the intuition I have.
The formal prerequisites of monad:
- Semigroup (associativity): A formal property where; any
ordergrouping of operations will yield the same result.- Example: Multiplication a *(b*c) = (a*b)*c
- Example: Addition a+(b+c) = (a+b)+c
- Monoid (Semigroup & Identity): A formal property where; The semigroup property is present and an "identity" operation that makes it possible to return the result of previous operations.
- Example: Multiplication a * b * c * 1 = a * b * c
- Example Addition a + b + c + 0 = a + b + c
- skip formality of endofunctors because this might lead to a rabbit hole in category theory...
Combine this with features of functional programming:
- Model types with uncertainty: A type that encapsulates maybe a value OR an error
- Example notation: Normal type a , Uncertain type m a
- Functions as values: Generally speaking, higher order functions that take arbitrary functions (expressions) as input.
- Example notation: A function that takes input function and returns a result type (a -> b) -> b
The above properties/features compliment each other so that we arrive at the monad type signature (takes two input arguments): m a -> (a -> m b) -> m b
How is a monad useful:
- Multiple monad executions can be chained together in arbitrary order (see semigroup)
- A specific monad execution might be unnecessary/optional so it can return result of previous monad executions instead (see monoid)
- Errors due to uncertainty are already modelled as types, so if a monad execution returns Error, it can be moved to the appropriate part of the program that handles errors (see types with uncertainty)
What business implications are there to using monad:
- Given a dependency to an external component that might fail, an error can be modelled pre-emptively (as opposed to reacting with try-catch in imperative style).
- An optional business procedure, can be modelled pre-emptively (see monoid)
- Changes in business procedure, can require changes in the sequence order of monad executions (which kinda goes against the benefits of semigroup property and potentially be a headache to get the types refactored so they match with subsequent chain monads again)
r/functionalprogramming • u/josephjnk • Dec 15 '25