r/functionalprogramming • • Apr 29 '19

FP Hitler reacts to functional programming

Thumbnail
youtube.com
344 Upvotes

r/functionalprogramming • • Sep 18 '24

FP My book Functional Design and Architecture is finally published!

308 Upvotes

Hi all,

This is such great news! My book Functional Design and Architecture has finally been released by Manning Publications!

😀😄😊😊😊❤️❤️❤️❤️

I worked on the book for many years: four years on the first edition, which was self-published in 2020, and four more years at Manning Publications. It was an enormous effort to provide you with a practical guide on how to build quality applications with statically typed languages such as Haskell, F#, Scala, OCaml, even C# and C++!

🔗 Check it out here: Functional Design and Architecture

➤ Functional programming has always had strong theoretical foundations, but when it comes to practical applications—especially large-scale systems—resources can be scarce. This book takes an engineering approach to FP, presenting a consistent methodology that blends architecture, design patterns, and best practices.

What’s inside:

  • A full-fledged methodology: I introduce the concept of Functional Declarative Design, which aims to provide FP with a robust, scalable approach similar to what Object-Oriented Design (OOD) has done for OOP languages.

  • Comprehensive knowledge: The book provides everything needed to build applications from start to end. This includes the tools for requirements collection, analysis, architecture design and development.

  • Software Engineering: The book describes various design patterns and principles, both from the mainstream world and new ones, and everything is merged into a practical and consistent methodology. The book gives special attention to functional interfaces, decoupling, SOLID principles, so that the code can be easily maintainable, testable and well-structured.

  • Cutting-edge ideas: The book introduces several new design patterns and a whole architectural approach called Hierarchical Free Monads.

  • Practical, not theoretical: The book uses Haskell, yes, but it's written for regular developers like me, not for overminds like other haskellers. The book is free from heavy academicism and abstract math. Just real-world tools, demos, and practices that you can apply to your own work immediately.

It’s been a privilege to get endorsements from key figures in functional programming like Scott Wlaschin (Domain Modeling Made Functional), Vitaly Bragilevsky (Haskell in Depth) and Debasish Ghosh (Functional and Reactive Domain Modeling). Their kind words and support have been immensely motivating.

Comprehensive, with simple and clear code examples, lots of diagrams and very little jargon!

-- Scott Wlaschin

Fill an empty slot in the field of software architecture. I enjoyed reading about Haskell applications from the perspective of dsign and architecture.

-- Vitaly Bragilevsky

Discussess the goodness of functional programming patterns in the context of real world business applications. It explains free monads beautifully.

-- Debasish Ghosh

And even more, I'm currently finishing my third book, Pragmatic Type-Level Design, which will advance Software Engineering in FP even further! It's more Haskell book than FDaA, but I'm aiming to provide universal approaches and ideas. The book is mostly written. I'm working on the appendixes and a special part called Rosetta Stone: all the same approaches I show in Haskell can somewhat be transferred to other languages. Expect it to be self-published by January 2025.

My goal is to make Functional Programming a viable and useful tool in our field!

Buy my books, support my work, and let's turn these dreams into reality!

My twitter: https://x.com/graninas
My GitHub: https://github.com/graninas
My LinkedIn: https://www.linkedin.com/in/graninas/

I’d love to hear your thoughts! 😊


r/functionalprogramming • • Jan 04 '25

FP I tried the Roc programming language for a couple of weeks and it’s now my all-time favorite language.

195 Upvotes

And I say this as an extreme polyglot programmer. I’ve used JavaScript, Python, C, C#, F#, OCaml, Haskell, PureScript, ReasonML/ReScript, Rust, Go, SML, Clojure, Scala, and probably some others, many of which I used at work at various times.

Prior to trying Roc, my favorite language was definitely OCaml. OCaml is fast and relatively easy to build stuff with, and it doesn’t force you to only use pure functions. It’s just a nice pragmatic “get shit done” language which is nice to work with and very expressive.

Roc does this better IMO. It’s a pure functional language, which I thought I wouldn’t like, but it honestly doesn’t get in my way. It beats Haskell IMO because it’s faster and has more predictable performance characteristics, but more importantly it’s simpler. It doesn’t end up in type-level abstraction to the heavens. I just write my functions with straightforward types and go on my way.

There are two reasons I think I really love Roc more than other languages.

First of all, the variant types (called “tags” in Roc) are basically like OCaml’s polymorphic variants. You can define a “closed” set of variants in a type definition, or you can make it “open”/extensible. More importantly they are global types. I can just return a Document Str type from a function and it will “just work” with third party code that also accepts Document Str without having to qualify it with a module namespace. You don’t even have to define them. Just use them and they just exist everywhere for any function. It’s so nice to quickly bang out a script without much type-level ceremony. It reminds me of TypeScript but with no need for a type declaration.

Polymorphic variants are my favorite language feature from OCaml, but Roc just makes that the only type of variant you get. It’s just a simpler language design.

Second, the platform-specific environment is amazing. You can use a “basic CLI” platform or a “basic web server” platform, or even embedded platforms. Anyone can just define a platform API and wire it up to the host code, and then you can call those functions from Roc. The calls to these platform-specific functions are wrapped in a Task type (similar to Haskell’s IO), which is basically just an async Result type. It’s simple to use and has a clean async-await style syntax sugar that looks super clean.

Imagine a simpler version of Haskell (closer to Elm, actually) that can easily run on an embedded system and beat OCaml and Go on performance in many cases without much perf-related contortions in your code. Just write straightforward functional code and it runs at blazing speeds.

The only problems I can identify with Roc so far are (1) the lack of some nicer higher-level string niceties (like a dedicated Char type), (2) it has a smaller package ecosystem than more established languages like Haskell, (3) the LSP is minimal and doesn’t provide type info as far as I can tell, and (4) it still has some minor compiler bugs to iron out.

So it’s definitely not production-ready for business use case IMO, but I can see it easily getting there. I’m currently writing a compiler in Roc, so it’s useful enough now for that purpose.

Oh yeah, and it’s incredibly easy to set up and get your code building. I did it in less than 10 minutes just following the instructions for my Mac. Basically zero configuration process.

You should try it out!


r/functionalprogramming • • May 26 '20

FP Hitler reacts to functional programming

Thumbnail
youtu.be
135 Upvotes

r/functionalprogramming • • Jun 26 '22

JavaScript Really good explanation of a monad in under 100 seconds

Thumbnail
youtube.com
125 Upvotes

r/functionalprogramming • • Feb 13 '26

Intro to FP How the functional programming in Scala book simplified my view on side effects

116 Upvotes

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 • • Sep 17 '26

FP Bend 2: a functional language that compiles to fast CPU and GPU code, with proofs

Thumbnail bend-lang.com
109 Upvotes

r/functionalprogramming • • Dec 27 '20

Scala What I Didn't Know About Functional Programming until 2020

Thumbnail
gist.github.com
103 Upvotes

r/functionalprogramming • • Sep 12 '24

FP 3 books every (functional) programmer should read

102 Upvotes

From time to time there are recommendations as to which books a programmer should read.

These are usually books such as "Clean Code" or "The Pragmatic Programmer".

However, these are mainly books that focus on imperative or object-oriented programming.

Which books would a functional programmer recommend? I can think of two books off the top of my head:

"Grokking: Simplicity" and "Domain Modeling made Functional"

Which other books are recommended?


r/functionalprogramming • • Mar 04 '24

Gleam Gleam v1.0.0 released!

Thumbnail
gleam.run
101 Upvotes

r/functionalprogramming • • Jan 31 '22

Rust HVM: the next-gen optimal evaluator is now 50x faster thanks to a memory layout breakthrough

Thumbnail
github.com
97 Upvotes

r/functionalprogramming • • Oct 06 '26

Gleam Gleam doesn't compile to Erlang source anymore | Gleam programming language

Thumbnail
gleam.run
96 Upvotes

r/functionalprogramming • • Apr 17 '25

Podcasts New Podcast About Functional Programming

96 Upvotes

Hello everyone! Together with Func Prog Sweden I've just launched a new podcast on functional programming! It's available on all the usual podcast platforms + YouTube

I'd love to hear your feedback + comments, and whether you have anyone you'd like to hear on the podcast. Also, if you'd like to come on the podcast and talk FP, please shoot me a DM!


r/functionalprogramming • • Nov 06 '22

FP Finally it clicked

95 Upvotes

I have been programming for years. But only in imperative languages like C or Python. Or more precisely, always only in imperative programming style. My beginnings go back even further to C64 Basic and 6510 Assembler.

When I wanted to learn Rust I reached my limits. My first thought was: "Why can't I change the variables? Why do I have to put 'mut' in front of everything?"

Eventually it occurred to me that Rust borrowed a lot of ideas from functional programming. So I started to look into it. I read books, I watched YouTube videos, and I tried to work through tutorials on different functional programming languages.

I basically understood what FP was about (purity, side effects), but I never understood how to implement it in a real project. Until just now.

I am currently reading the book "Mastering Functional Programming" from Packt Publishing (No advertising). I don't know if it's specifically the content of this book or just the sum of all the information from the last few months, but something clicked for me.

I think I understood the difference between imperative and declarative. I think I understood what is meant by "functional core, imperative shell".

I'm going to finish reading the book as much as I can now, and then set about finally learning Rust (and maybe even a pure functional language.


r/functionalprogramming • • Feb 01 '23

Intro to FP Exercism are running Functional February

92 Upvotes

Hello 👋 I'm Jeremy, the co-founder at Exercism (the free, not for profit coding educational platform).

We're running a year long challenge to encourage people to try different programming paradigms and languages, and for February we're focussing on functional languages. We have lots we're planning including interviews with Jose Valim (creator of Elixir) and Louis Pilfold (creator of Gleam) and lots of live-streaming of people solving exercises in functional ways! I thought it might be of interest to some people in this community.

(To be clear: We're not trying to sell you anything. Everything really is free (we survive on donations). Our mission is to help as many people as possible get better at programming. And I really do think this might be of interest to people here, but please delete if this is considered spammy!)


r/functionalprogramming • • Feb 24 '24

Intro to FP What's the best language/material for learning function programming?

86 Upvotes

I've read a lot of post on this now but here's my take and phrasing of the question.

I just want to learn functional programing for personal development. I'm a pro java guy during the day so I'm not needing to get a job out of it, before anyone tells me to learn scala. I'm currently using sicp to learn and I like it so far but it is quite a long book so I'm starting to feel like there's a more productive path since I honestly don't care about the language it's the concepts etc I'm after. The main thing I don't want to do is learn some of the style in a language I already know like TS or Java as this is supposed to be fun and these languages make me think about work.

Any comments on your journey or what you think is good or worked etc would be great

Thanks


r/functionalprogramming • • May 07 '24

FP Slides of my talk "Functional Programming: Failed Successfully:

82 Upvotes

Hi folks, yesterday I presented a talk "Functional Programming: Failed Successfully" at u/lambda_conf.

This is an important talk to me about the subject that bothers me a lot in the past several years. Enjoyed speaking about it. Will be waiting for the video; here are the slides anyway:

https://docs.google.com/presentation/d/10XX_g1pIWcVyH74M_pfwcXunCf8yMKhsk481aVqzEvY/edit?usp=sharing


r/functionalprogramming • • Nov 25 '25

FP What's the Point of Learning Functional Programming?

Thumbnail
blog.daniel-beskin.com
80 Upvotes

Based on true events...


r/functionalprogramming • • Mar 06 '26

Intro to FP My clean code habits were actually State Monads

79 Upvotes

Reading Functional Programming in Scala. This is my second post here to share what I am learning.

I have been a full-stack developer for 15 years, mostly using OOP and imperative styles. I always tried to avoid global state because it makes code hard to debug. My solution was usually to pass a "context" or "config" object through my functions to keep things organised.

When I reached the chapter on State, I realised that what I was doing manually has a formal name: the State Monad.

A simple code example:

Imagine we are counting how many times a user clicks a button.

The Imperative Way (Hidden changes): In this version, the function reaches outside of itself to change a variable. This is a "side effect.":

count = 0

def increment():
    global count
    count += 1
    return "Clicked!"

# You call it, and the 'count' variable changes in the background.
result = increment()

Functional Style (The State pattern):

def increment_pure(current_count):
    new_count = current_count + 1
    return ("Clicked!", new_count)

# You call it, and you get back the result AND the new state.
result, final_count = increment_pure(0)

# Usage
result, final_state = add_user_pure(initial_db_state, "Avinash")

What I learned from this:

  • Honest Functions: In the first example, you don't know the function changes anything just by looking at its name. In the second example, the code tells you exactly what it needs and what it gives back.

  • Easier Testing: I don't need to "setup" a global variable to test my code. I just give the function a number and check if it adds 1 correctly.

  • Safe for Growth: When your app gets big, having functions that don't touch global data makes it much harder to break things by accident.

It is interesting to see that "best practices" I learned through trial and error are actually core principles in functional programming. I am still learning.

For those who moved from OOP to FP What other patterns were you already using before you knew the formal FP name for them?


r/functionalprogramming • • Mar 13 '25

FP I've created ZeroLambda: a 100% pure functional programming language which will allow you to code in raw Untyped Lambda Calculus

79 Upvotes
  1. You will always code in pure low level lambdas

  2. You will have to build every primitive from scratch (numbers, lists, pairs, recursion, addition, boolean logic etc). You can refer to Church encoding for the full list of primitives and how to encode them

  3. ZeroLambda is an educational project that will help you to learn and understand any other functional programming language

  4. There is nothing hidden from you. You give a big lambda to the lambda machine and you have a normalized lambda back

  5. ZeroLambda is turing complete because Untyped Lambda Calculus (UTC) is turing complete. Moreover, the UTC is an alternative model of computation which will change the way you think

  6. You can see any other functional programming language as ZeroLambda with many technical optimizations (e.g. number multiplication) and restrictions on beta reductions (e.g. if we add types)

  7. The deep secrets of functional programming will be delivered to you very fast

Check it out https://github.com/kciray8/zerolambda


r/functionalprogramming • • Nov 05 '23

Question Why is functional programming so hard

78 Upvotes

Throughout my entire degree till now, I’ve been taking OOP. Now I am in a FP course and I am struggling a lot. I understand it’s almost a total different thing. But I just failed a midterm in FP in Ocaml. I swear I could’ve solved the questions with my eyes closed in OOP. What am I doing wrong, why can’t I get a grasp of it. Any tips on how I should approach studying this.


r/functionalprogramming • • Jun 19 '21

Intro to FP Intro to functors, bifunctors, and profunctors

Thumbnail
youtu.be
78 Upvotes

r/functionalprogramming • • Dec 28 '21

Intro to FP Intro to Monads, for software engineers new to monad-y thinking

Thumbnail
youtube.com
76 Upvotes

r/functionalprogramming • • Jun 05 '22

OO and FP Design Patterns Book for functional programming?

75 Upvotes

A little background: I'm fairly new to the functional world but have decided I really want to head that direction in general in my programming. I write mostly in TypeScript and I prefer to do things as "functional" as possible. It just brings so much clarity and correctness!

I've worked through most of How to Design Programs and that's been super helpful in terms of learning how to break down and solve problems through a "wish-list" of functions etc, recursion, processing S-expressions, etc, etc. Great stuff! I find I can tackle really complex problems now that would have absolutely baffled me before.

I'm also thinking of working through SICP next, but my question was: I was wondering if I should dig into the classic "Design Patterns Elements of Reusable Object-Oriented Software." Are those patterns helpful for people wanting to look at things in a more functional way? Is it even necessary or, can everything be tackled in a different paradigm? Is there a book that people would reccomend instead?