Pure Functions in FP

The cluster discusses the concept of pure functions without side effects as central to functional programming, debating definitions, enforcement in languages like Haskell, and distinctions from impure code.

📉 Falling 0.3x Programming Languages
3,525
Comments
20
Years Active
5
Top Authors
#7464
Topic ID

Activity Over Time

2007
3
2008
5
2009
71
2010
38
2011
93
2012
100
2013
207
2014
183
2015
225
2016
267
2017
223
2018
173
2019
213
2020
310
2021
295
2022
295
2023
353
2024
257
2025
205
2026
9

Keywords

OO e.g OP IMO OK OOP en.m FP ycombinator.com E.g pure functional functions function effects purity fp haskell state functional programming

Sample Comments

valenterry Oct 28, 2020 View on HN

It's not explicitly expressed (the functions could still execute sideeffects and e.g. mutate things), but yes, that is pretty much the style that pure functional programming enforces!.

peaton Jul 1, 2014 View on HN

That's a little vague, I think. Pure functional programming has no side effects. Isn't that as succinct & thorough as it gets?

vezzy-fnord Jul 8, 2015 View on HN

Author's obviously talking about pure functions, not procedures or subroutines.

interlocutor May 31, 2021 View on HN

Being explicit about effects does not make the function pure, does it? Why claim FP credentials if all or most of your functions are going to be impure?

viscanti May 8, 2012 View on HN

That's exactly what functional means. You're conflating functional and pure. They happen to be (essentially) the same thing in Haskell, but that's not always the case. A functional language can get you really close to pure (but good luck doing anything interesting without monads or mutable state), but even the purest languages cheat. Putting your side-effect code in a main function might help you catch bugs and limit potential side-effects, but it's still not completely pure (and for good re

flowerlad Nov 2, 2020 View on HN

Pure functions (with no side effects or state mutation) is pretty core to functional programming.

CmonDev Aug 14, 2015 View on HN

Purely functional, or simply not having side-effects and using immutability? No need to go full-Haskell to benefit.

melling Jun 30, 2017 View on HN

Isn't he just rediscovering the idea of pure functions?https://en.m.wikipedia.org/wiki/Pure_function

Sssnake Nov 24, 2013 View on HN

Without side effects you couldn't do anything. Pure functional languages make side effects explicit, but it isn't about them being missing.

jb1991 Feb 18, 2023 View on HN

The language does not offer the features that you were referring to, and that the author of the article mentions. You can write pure functions, but the purity is not checked by the compiler, that is what has been meant here.