r/functionalprogramming • • Sep 25 '23

Question Why OOP sucks?

4 Upvotes

r/functionalprogramming • • Dec 31 '22

Question Why is Semigroup called Semigroup when it’s very different than the mathematical term?

0 Upvotes

It’s a type and a combination function where as in math it’s a set and a combination function. Why choose an abstract name for something when it’s not even the same as the functionality from you borrowed the name from? Why not just pick a simple name like Combinable instead. Then it would make the most sense.

Unless I missed something here it’s a borrowed name for something that is just similar but not the same. It’s unfortunate because it makes concepts like this harder to learn because of the confusion between the mathematical meaning and the meaning in computing. It is also harder because the name is very abstract. I’m math it makes sense through because of where it inherits from etc

Please help me understand the motivation why Semigroup is a good name for such a construct


r/functionalprogramming • • Jul 21 '20

Scala Why does Scala win against Kotlin? Senior engineer's opinion.

Thumbnail
scalac.io
3 Upvotes

r/functionalprogramming • • May 20 '26

Question Which Functional language is best for AI assisted development?

5 Upvotes

What FP languages work best with AI agent driven development, and what tools/skills/mcps make the most difference in your workflow?

Everyone knows that an LLM will choose TS or Python if you don't prompt it towards another tool. But this doesn't bring much joy.

But something about a dynamic fp, or a strongly typed ML just brings more joy when it comes to reading the generated code.

However -- my experiments with FP and Claude code have been less than ideal. I found that Ocaml/Clojure will overall spend about 10x the tokens iterating on a solution until it is correct.

There are some really promising signs though -- the clojure-mcp-light parenthesis edit and nrepl utility make an objective improvement in terms of overall quality. I saw 2x the number of tests written, and overall what I think is a more concise and correct solution.

I love picking up new languages, and I am very interested in testing MCP's and skills which can actually objectively improve the quality of a solution, so really I want to have some recommendations on what languages to try next :)


r/functionalprogramming • • Jun 28 '24

Question Does Lazy Evaluation have a Future?

2 Upvotes

In Haskell it is used for deforestation to keep the stack low. But after some experience with it, it is simply a problematic concept.
UPDATE: What do you think about a concept with buds?
Buds that change from unbound to bound via a side effect,
which can be checked beforehand with isbound. Wouldn't a concept with buds be much more flexible.


r/functionalprogramming • • 16d ago

News I tried Bend 2: formal verification with AI, parallelism. My thoughts.

Thumbnail
youtube.com
0 Upvotes

It's a 21 minute video. The first 9 minutes are demos and walkthrough. The technical explanations and my thoughts start at 9:56.


r/functionalprogramming • • Apr 17 '21

Python i realized i got too used to functional programming when i did this

3 Upvotes
def curry(func):
    def new(*args):
        def inner(second):
            return func(args[0], second)
        if len(args)==0: return new
        if len(args)==1: return inner
        if len(args)==2: return func(*args)
        raise Exception()
    return new
def pipe(*funcs):
    def returned(*args, **kwargs):
        for func in funcs:
            args = [func(*args, **kwargs)]
        return args[0]
    return returned
def fullinverse(insts):
    return pipe(curry(map)(inverse), curry(map)(str), ''.join)(insts)

r/functionalprogramming • • Nov 18 '17

FP Functional Programming Makes Your Better

Thumbnail
functional.works-hub.com
2 Upvotes

r/functionalprogramming • • Apr 03 '25

OO and FP OOP vs. Functional is Dead

Thumbnail
medium.com
18 Upvotes

r/functionalprogramming • • Sep 14 '25

Question Convince me that functional programming is as useful to me as OOP and introduce me to this world

0 Upvotes

Okay, first of all, I don't exactly know what functional programming is. I've seen a feature or two in some programming language, but I've never really immersed myself in this world.

One more bit of context I wanted to share about myself: I work with data analysis and machine learning, especially in Python with Polars and lots of plots. But in my free time and on personal projects, I like to use languages ​​other than Python (I don't really like the nature of scripted implicit non-typed languages for my personal projects, I only use Python for data or AI related stuff)... My personal projects include languages like Go and Java, and I have to admit that I like (and find useful) object-oriented programming, I can think intuitively with it. And about my projects, I like to do desktop utilities softwares, and that's exactly why I like non-power users being able to use my applications with no problem.

And I'm always researching other technologies as well, but one criterion I take very (really very) seriously is that I don't care much about theoretical/academic arguments about X or Y (I see this happening a lot with functional paradigm nerds talking about Haskel, but whenever I try to look, I don't see much immediate practical use for it for me...); I'm more serious about whether I can be productive in practice with something and whether I can actually produce a complete product with it. And by 'complete product' I mean not only that it has its features and an incredible engine or API running in the background, but that it has a graphical GUI and a user who isn't a power user can also use my applications easily.

So please, help me understand and introduce me to this functional programming world:

  1. What is functional programming exactly? What is the productivity flow like with the functional paradigm versus the object-oriented one?

  2. Can I be really productive with a functional language (or not necessarily the language, but using only the functional paradigm) in the sense that I explained before of being able to produce a 'complete product'?

  3. If the answer to the previous question is yes, then what languages ​​should I look at using perhaps as my functional language?

Thank you for your time!


r/functionalprogramming • • Jul 03 '22

Category Theory Solving Data Integration with Categories (Cats)

0 Upvotes

I'm going to post this here since the FP crowd tends to be early adopters, but I think FP and Cats actually serve different use cases. That is, you can still do FP with "cats" ... it's just another tool in the toolbox

The seeds for the Multix "categorical machine" were first planted by John C Reynolds when I was at Carnegie-Mellon (he has since passed away). John opened up some holes in my understanding of computer science using ALGOL (!!) that haunted me for decades

https://multix.substack.com/p/solving-data-integration-with-cats


r/functionalprogramming • • Nov 12 '13

What’s Wrong with OOP and FP

Thumbnail
yinwang0.wordpress.com
1 Upvotes

r/functionalprogramming • • May 17 '21

Question Mutable closures break FP? If so, how is FP doing nowadays?

0 Upvotes

https://www.reddit.com/r/functionalprogramming/comments/ndlso9/do_you_consider_programming_with_only_clousures/gycrxi2?utm_source=share&utm_medium=web2x&context=3

If you believe that classes break FP, then you must believe that closures do as well.

Apparently realworld programming with only pure functions is not a solved problem today. Though Algebraic Effects & Handlers is seemingly the faithful future, it hasn't matured & got battle tested yet.

Before that, is FP considered broken for now?


r/functionalprogramming • • Aug 07 '18

JavaScript Amusing interviewers with Functional Programming

Thumbnail
medium.com
0 Upvotes

r/functionalprogramming • • Nov 22 '19

OO and FP There Are no Upsides to Object Oriented Programming

Thumbnail
medium.com
5 Upvotes

r/functionalprogramming • • Dec 30 '23

Question Is there any modern FP language in terms of design and ecosystem?

2 Upvotes

I can write Haskell and OCaml but they are both outdated especially in terms of their standard libraries' design, documentation and ecosystem like formatter, linter, package manager, built-in testing library etc. (By the way, I don't think their syntax is so outdated.)

I can also write Rust and Go, and love how they are modern but they are not FP languages (though Rust is inspired by many FP languages and very similar to Haskell and OCaml).

Is there any modern FP language?

By "modern", I mean

  • Standard library is easy to use AND its design is consistent with the ones in other languages. (For example, not regex_replace <regex> <string> <new> <old> (OCaml) but regex_replace <regex> <string> <old> <new> (like in many languages).)

  • Documentation is beautifully styled (indent, colors, etc.) and detailed. (For example, compare String in Haskell with String in Rust.)

  • Ecosystem is modern: formatter, linter, package manager, built-in testing library, etc. (For example, golangci-lint for Go comes with tens of lints.)

  • Cross-platform (at least Windows, macOS and Linux)


r/functionalprogramming • • Oct 14 '20

Intro to FP Does Functional Programming Make Your Code Hard To Read?

Thumbnail
dev.to
2 Upvotes

r/functionalprogramming • • Aug 28 '25

Question Big tech internship vs FP course at university

2 Upvotes

What will be more useful for a third-year CS student: taking a functional programming course at university or getting real experience through a big tech internship instead (I can take something much easier)?

It feels like this course would be very useful for the 10x engineer path (is it really? wouldn't it be useless without experience with large systems?). On the other hand, getting real work experience is obviously important in any case. Especially since I've already passed most of the interview stages in one big tech company, there are only trifles left.


r/functionalprogramming • • Dec 15 '24

OCaml Ocaml Brings Multi-disciplinary Logic, Math, Science, and Engineering Together

Thumbnail reddit.com
1 Upvotes

r/functionalprogramming • • Oct 24 '14

Intro to the Ideology of Functional Programming

Thumbnail
gebert.sexy
0 Upvotes

r/functionalprogramming • • Aug 28 '24

Question If FP can't use UML Class Diagram, then how do you represent your systems?

0 Upvotes

There are no classes in FP.

So how do you even model a system if you cant use a good old UML Class Diagram?


r/functionalprogramming • • Nov 25 '25

Question AI driven functional programming with Typescript

5 Upvotes

Background:

I've been using fp-ts for pure functional programming in TypeScript for a few years. Love the composability with pipes, map/flatMap/tap abstractions, and typed error handling.

The Problem:

Since fp-ts is relatively novel and TypeScript is un-opinionated, LLMs generate wildly inconsistent code. I'm seeing:

  • 300+ line functions

  • Tricks to use native async/await instead of Task/Either

  • Code that's harder to refactor than writing from scratch

My Solution (so far):

I've created:

  • Multiple CLAUDE.md files for different fp-ts patterns (fastify API, app-lifecycle, if-cases)

  • 18 custom eslint rules to enforce functional style and reduce complexity

Some rules include:

  • no-long-inline-functions-in-pipe

  • no-async-await

  • no-nested-pipes

  • enforce-file-layout

Still Struggling:

Even with these guardrails, LLMs still produce less readable code and don't use fp-ts to its fullest. Examples:

  • Returns () => Promise.resolve(1) instead of t.Task<1>

  • Struggles with concepts like a.traverse(te.ApplicativePar) and other fp paradigms

  • Always falls back to TypeScript-native imperative style

Considering Alternatives:

I'm thinking about dropping fp-ts for future projects and just using eslint rules for native TypeScript. I want to stick with TypeScript for the ecosystem, but PureScript seems too novel for my team.

Question: How do you handle FP with TypeScript? Do LLMs like Sonnet 4.5 perform better with other FP languages?


r/functionalprogramming • • Apr 29 '26

TypeScript I built a TypeScript toolset that enforces Haskell-style purity discipline — because AI writes code faster than humans can review it

0 Upvotes

▎ I've been thinking about a problem: AI assistants can now generate thousands of lines of TypeScript per minute. But TypeScript's flexibility means any function can secretly perform network calls, mutate global state, or access the environment —
▎ and none of this shows up in the type signature.
▎
▎ So I built haskellish-effect-ts — a suite of npm packages that enforce Haskell-style discipline in TypeScript using Effect-TS:
▎
▎ - Side effects must be wrapped in Effect — no hidden I/O in plain functions
▎ - Closed-world model — if you didn't import it, you can't use it
▎ - Global environment blocked by default — fetch, console, Date require explicit import
▎ - Escape hatches exist, but are clearly marked (like Haskell's System.IO.Unsafe)
▎
▎ The idea: if a function has side effects, the type system and linter will tell you. Instantly. Before review.
▎
▎ Here's what it looks like in practice:

import { Effect, pipe } from 'haskellish-effect'

// ✅ Side effects are explicit — the return type tells you everything
const fetchUser = (id: number): Effect.Effect<User, FetchError> =>
  pipe(
    tryFetch(`/api/users/${id}`),
    Effect.flatMap((r) => Effect.tryPromise({ try: () => r.json(), catch: (e) => e })),
    Effect.flatMap(Schema.decodeUnknown(User)),
  )

// ✅ Pure function — no Effect, no surprises
const greet = (name: string): string => `Hello, ${name}!`

// ❌ ESLint error: 'fetch' is not allowed — use tryFetch from haskellish-effect
const sneaky = () => fetch('/api/secret')

// ❌ ESLint error: direct 'effect' imports are blocked — use haskellish-effect
import { Effect } from 'effect'import { Effect, pipe } from 'haskellish-effect'

// ✅ Side effects are explicit — the return type tells you everything
const fetchUser = (id: number): Effect.Effect<User, FetchError> =>
  pipe(
    tryFetch(`/api/users/${id}`),
    Effect.flatMap((r) => Effect.tryPromise({ try: () => r.json(), catch: (e) => e })),
    Effect.flatMap(Schema.decodeUnknown(User)),
  )

// ✅ Pure function — no Effect, no surprises
const greet = (name: string): string => `Hello, ${name}!`

// ❌ ESLint error: 'fetch' is not allowed — use tryFetch from haskellish-effect
const sneaky = () => fetch('/api/secret')

// ❌ ESLint error: direct 'effect' imports are blocked — use haskellish-effect
import { Effect } from 'effect'

▎ Setup is one import:

bun add haskellish-effect
bun add -d haskellish-effect-config eslintbun add haskellish-effect

- - -

// eslint.config.js
import { strict } from 'haskellish-effect-config'

export default [
  ...strict,
  { languageOptions: { parserOptions: { project: true, tsconfigRootDir: import.meta.dirname } } },
]// eslint.config.js
import { strict } from 'haskellish-effect-config'

export default [
  ...strict,
  { languageOptions: { parserOptions: { project: true, tsconfigRootDir: import.meta.dirname } } },
]

▎ GitHub:
▎ - https://github.com/aiya000/haskellish-effect-ts
▎ npm:
▎ - https://www.npmjs.com/package/haskellish-effect
▎ - https://www.npmjs.com/package/haskellish-effect-config
▎ - https://www.npmjs.com/package/eslint-plugin-haskellish-effect ▎ Would love feedback — especially from folks who've thought about purity enforcement at scale, or who work with AI-generated codebases.

r/functionalprogramming • • Feb 09 '23

Question How do Typescript and Haskell deal with the fact that the typed Lambda Calculus is inconsistent?

1 Upvotes