so in #ideas > Purity Inference I used the term "effectful" function to describe a function that isn't pure. My reasoning was that "impure" function sounded unnecessarily judgmental; it's not like I should feel bad for writing or using a function like that, it just means I'm getting a different set of tradeoffs compared to pure functions!
but someone pointed out to me that "effectful" suggests it's doing side effects, but that's not necessarily the reason it's not pure
for example, it could be just reading from external state other than its arguments, in a way that doesn't actually change the outside world at all - so, not really an "effect" per se, but still disqualifying the function from being pure (and e.g. benefiting from compiler optimizations that are safe to do only on actually pure functions)
so maybe "effectful" is the best name for those, but I'd like to explore alternative terms and see if we can find a better one!
one that interests me is "pure function vs stateful function" - in the sense that it's either reading or writing external state
that feels in some ways more accurate than "effectful" but a thing I don't like about it is that it kinda feels like it's saying "this is a function where in my own code I've defined some state which travels with the function" rather than "this is a function which interacts with state in the outside world"
like how in some languages it's possible to make a lambda that captures a mutable object and both modifies and reads from it - that's what I think of when I hear "stateful function"
another idea is "pure functions vs procedures" where a procedure is allowed to do side effects, read from external state, etc.
a thing I don't like about that is that historically, procedures haven't been closures - they don't have a concept of captures, etc.
open to any thoughts and ideas on this! :big_smile:
I don't like procedure, because often it has become a name used almost interchangeably with function. I think in nim, they use func or (mostly) pure functions and proc for impure ones, but I think it will just be a distinction to learn for newcomers rather than it being intrinsic to the name. I am not a native English speaker however, so maybe it is intrinsic.
I like stateful a lot better as it implies what is meant. Maybe it doesn't cover everything an impure function can do, but both external and internal state are covered. So I/O and randomness are covered as well as things like mutating closures
As a native English speaker, "pure function vs. procedure" is not an English thing intrinsically
One thing I like about procedure is that it is quite dry. Though there can be preconceptions, I think they are not super common. And I think it would be easy to learn “functions are pure, procedures are not”
It does feel like we're just pushing down the road if we say "we'll just tell people what procedures actually mean"
Which is why unless we find a better synonym, effectful and stateful seem like the only options so far that are directly explanatory of the behavior here
another idea is to reuse existing terminology - "Task".
My 2 cents: the word "function" is derived from mathematics, in which it means a mapping from inputs to return values (although in imperative programming languages, it doesn't have this meaning). However, words like "procedure" and "task" make it clear to me that it's a sequence of things being done, differentiating themselves from "functions". Especially in a functional programming language, I think the terms "function" and "procedure" are sufficiently distinct, because people should already have the preconception that functions are pure
(I don't have a preference between "procedure" and "task")
That’s exactly what I was thinking Akshay :)
Though I slightly prefer procedure, as I think task has more preconceptions regarding asynchrony
I thought it was called effectful because it was ran by an effect interpreter. :thinking:
I've been trying to imply "might perform side effects" when I say effectful
Perhaps slightly more contrived: function vs interaction
I feel like a Latin expert would have the solution to this word problem.
Like we want to convey a thing that can be effectful but may not. It has the ability to do things.
A terse term for "not deterministic/referentially transparent" would suffice
Richard Feldman said:
for example, it could be just reading from external state other than its arguments, in a way that doesn't actually change the outside world at all - so, not really an "effect" per se, but still disqualifying the function from being pure (and e.g. benefiting from compiler optimizations that are safe to do only on actually pure functions)
Schrödinger's cat may disagree. :sweat_smile:
I think it's fine to say that reading from external state is an Effect.
I think there's value in the terms being opposites (regardless of what the actual terms are). I like that I can teach one concept and then the other one is almost free. "Pure means that it's a lookup table of values: give it X and it'll give you Y, always, regardless of the time or your database, and it won't change anything anywhere either." then explaining impure is just "It's not pure. There's no guarantee that the function returns the same value given X, and it may change stuff like your database." and that's easy for someone to grasp. They learn one (whichever clicks with them) and can recall the other as the opposite. That's neat!
From Claude
"Pure vs. Contextual" has the advantage of being relatively neutral while still conveying the key distinction: pure functions operate in isolation, while contextual functions interact with or depend on their environment in some way. This pairing avoids the potential misunderstandings of "effectful" or "stateful" while still being descriptive and forming a clear opposition.
If you prefer to stick closer to established terminology, using "Pure vs. Impure" but consistently explaining that impurity is not a negative quality, just a different set of tradeoffs (as Richard initially suggested), could help reshape the perception of the term over time.
ChatGPT
Pure vs. Contextual:
Pure vs. Stateful:
Pure vs. Impure (with Reframing):
Pure vs. Effect-Possible:
Pure vs. Interacting:
Pure vs. Externalized:
"Isolated" is also a clear way to describe a pure function. Don't know the opposite of "isolated" though. Contextual? Cramped? Surrounded by loved ones?
Chat Gippity seems to be getting at "interacts with the outside world" the most
unconventional but kinda self explanatory: pure functions vs leaking functions
As much as it may be irrational, I agree with Richard that we want to avoid negative names, and pretty much anything that's the opposite of "pure" will get that drawback. So leaking, impure, non-deterministic, etc. I think are gonna be a hard sell
Obviously pure vs useful cause useful functions are the only ones that actually do anything.... :lol:
Though more seriously, I think interactive, active, effectful, io, or something along those lines is what we want to do for.
Pure vs io functions
pure vs interactive functions
...
Both of those sound decent to me
Active I haven't seen yet... There's value in a word that's sufficiently generic
Interactive also looks good to me
IO feels good mainly for historical reasons, not for beginners
I don't think we should go with stateful. I can almost guarantee that if I wrote down a function that just made a GET request and asked my coworkers if it was stateful, they would all say no.
Totally agree
We also could go with pure vs platform functions
Cause platform function fundamentally call to the platform which is the only part of a roc executable that can do io or any other effects
I don't think the terms being opposites is very important. If I say that "an impure function is one that cannot be a lookup table", that doesn't really tell me much about what an impure function can do. It might just be the case that it could read from external state but not write to it, for example.
:heart: pure vs io functions
simple and to the point
I'm not a fan of platform function because you can still have pure functions that are defined by a platform
My favorites right now are io and active
Well, we can't tell, right? If it's a platform function, you have no idea if it's pure. The only way to know from the Roc side is if it's entirely written in Roc/Roc std lib
Brendan Hansknecht said:
We also could go with pure vs platform functions
Cause platform function fundamentally call to the platform which is the only part of a roc executable that can do io or any other effects
true, but you can define your own in applications which call the ones you got from the platform, so then you end up with "ok now write a new platform function in your application..." :sweat_smile:
I think active is nice because it's short haha
I think IO gets at the idea that the function might read from external state
But it could do any number of things, I think IO is too specific
Well, we can't tell, right? If it's a platform function, you have no idea if it's pure. The only way to know from the Roc side is if it's entirely written in Roc/Roc std lib
It might not actually be pure, but it is still pure in the -> vs => sense
But it could do any number of things, I think IO is too specific
Yeah it is definitely an expansion of the concept of IO
I blame Haskell for this issue
An advantage of IO is that it I suspect it would be easier to guess what in IO function is than an active function from the outside.
I think IO is a general enough term and is easy to grasp
So, we have "pure functions" and "IO functions"?
I get that many may think specific at first, but it is overall a pretty general concept
When I see I/O I think input and output and don't associate that with non-pure at all.
By definition input and output have to be impure
So I think that is fine
I guess it depends on where you draw the boundary and if you're looking into the system or out of it.
Anyway I would rate the roughly:
Luke Boswell said:
Lol, I guess it depends on where you draw the boundary and if you're looking into the system or out of it.
The nice part is that we get to write the definition and people only have to learn it once
This is unironically a great opportunity for some ranked choice voting system
Just a poll might not do it
Star voting!!!
I'll take the internet points, then
It's election season in the US... I think we should make it mandatory and use a preferential system
But that's my exotic Australian opinion on the topic of voting systems
Assuming we call -> functions pure functions, what should we call => functions? In alphabetical order:
React to whichever versions you'd be okay with
Luke Boswell said:
I guess it depends on where you draw the boundary and if you're looking into the system or out of it.
Isn't I/O generally associated with external read/writes like filesystem, db, API, etc. ? Which would be out of the system.
Before we make a poll, should at least wait for any other ideas
In all seriousness, I still really like effectful.
One of the main reasons is that draws out the whole idea of Effects and purity into the normal conversation. So people will be talking and thinking about these concepts when they are using roc.
I also like that it's as simple as, these are run using an "effect interpreter" which is a machine in the platform that can do things in the real world.
yeah also on a meta-level I'm not a fan of polls as a way to advance design discussions because I'd rather focus on getting all the perspectives out there and understanding their tradeoffs
Good point
I'll try to avoid them in general. It seemed appropriate here because we were just throwing out opinions without a sense of movement towards agreement
The great thing about having a BDFN is we dont need agreement :smiley:
But yes, polls can push people with unpopular positions away from discussions where their opinions help us all get somewhere better
See @Brendan Hansknecht 's existence
well consensus is still important haha
although not always fully achievable, to be fair
We can be all care and no responsibility... if it turns out to be the wrong choice we can all blame Richard :sweat_smile: (no pressure or anything)
All of the pressure, actually
I knew what I was signing up for!
:thinking: maybe we could explain "effectful" as "causing an outside effect and/or being influenced by outside effects"
Outside is a bit strange cause it could be something like stored which is still app internal state.
Also, I would note the most important part which is the result may vary on every single call
But I feel confident we can come up with a very clear definition
I think it's not "more important" enough over "the outside world changes" to be the "most important"
But it's quite important
oh I meant outside as in outside the function
so like not its arguments or return value
Oh, that was not how I read that. Outside I thought was a vague description of io
Like outside the program
It might be different for native speaker, but at least to me, "procedure" always sounded like a series of instructions that may affect the world. As opposed to a "function", which we learn from math to be more of a mapping from input to output.
I think it's the one I like the most of the options discussed here, but I'm also ok with "effectful".
My reasoning was that "impure" function sounded unnecessarily judgmental
I like "not pure"
Or non-pure if it needs to be a one-word adjective
Agus Zubiaga said:
It might be different for native speaker, but at least to me, "procedure" always sounded like a series of instructions that may affect the world. As opposed to a "function", which we learn from math to be more of a mapping from input to output.
For me I think the issue with procedure is that it just feels like only output is importat. When arguably input from the world is the more important part in terms of guarantees.
I remember a clojure person using the terms "calculations" (pure) vs "actions" (impure). To me, it has the benefit that reading from outside the program sounds more like an action, but then 'calculation' requires some "but not just math" explanation.
Functions and actions are a good approach, it doesn't require qualifying the function type
I think the term pure might also not be helpful, because it just says "this is what a function is actually supposed to be, mathematically" and then you need to find an adjective that says "this is not an actual mathematical function".
So since this is about dependencies being explicitly listed in the arguments versus implicitly used in the body, here might be some other word pairs that I don't think I've read in this thread:
Another option:
I hope there are some new ideas for you in there. :wink:
I like "closed vs open", feels very intuitive.
Hello, new here. I would like to add in 'Strict vs Compliant' functions as an alternative.
Welcome @Syntax :)
Why wouldn't a non-deterministic function also be an effectful function? In Koka, the "pure" function would mean a function with 0 effects, whereas a non-deterministic function would have 1 effect called 'ndet'.
Yeah I personally am very content with calling impure functions effectful
I think the bar should be higher for terms that aren't used this way anywhere else
years ago, before "pure function" was mainstream in the JavaScript community, I tried to make "stateless function" happen in the hopes that it would be more intuitive for people to understand
it absolutely did not take, even a little bit :sweat_smile:
but eventually "pure function" became mainstream in that community
so I think "pure function" as one of the two terms is a very strong frontrunner, and the bar would be high for any choice other than that
but I don't think there is a mainstream term for the opposite
like I don't hear people talking about "impure functions" all the time for example
It could be called a "free function" in the sense that a pure function is restricted in what it can do, while a free function can do whatever it wants. That way both terms have a word with positive connotations. No strong feelings about this, just spitballing.
Richard Feldman said:
like I don't hear people talking about "impure functions" all the time for example
ditto. I do hear people talking about "effectful" functions sometimes though, but they don't necessarily mean an impure function. They usually mean a function that "does something" like database calls, API calls etc. Perhaps that's close enough.
Free is a good term because it captures that the function isn't guaranteed to have effects, it's just free to do them
I like 'active function' that was mentioned before. Bit vague, but I think evoking the right intuition.
Alternative on 'free function': 'unconstrained function'.
"functions without borders"
I think either impure or effectful is fine. The nice thing about impure is that it very clearly defines that it's not pure. I don't feel that either pure or impure have a value judgement to them. I'm not sure why someone would think there is a value judgement
The problem with "impure" is that to someone who knows English but not functional programming, "impure" means unclean or subpar. It makes it sound like impure functions are something to be avoided, like if you write them you're not a good enough programmer to write good pure functions.
It's possible to teach that it doesn't have that judgement in this context, but the word choice wouldn't help.
I like "effectful". It's a little weird to say that something like Time.now has an effect when nothing in the outside world changes, but I think that's easy enough to teach: From the language's perspective, a function that reads from the outside world needs the same care as one that causes an effect (because of caching, fragile tests, platform support, etc), so it makes sense to group them together and treat them all as if they're "effectful (programming term)", whether or not it actually has an "effect (English word)".
We also could slightly modify effectful or add an extra word for clarification.
For example:
Maybe some minor change from effectful could be the most clear.
effectable :laughing:
effectalicious :yum:
I've just stumbled onto the term "operation" in the book Domain-Driven Design (chapter 10, section "Side-Effect-Free Functions").
It's not really used as the opposite of pure functions, but while reading I had to think of this discussion.
If we don't want to switch the noun, maybe it could be an operating function?
I'd like to suggest "non-pure".
I don't think it really has negative connections like impure. But also it avoids the "Getting time isn't really effecting things " issue.
Plus for people coming from other functional languages it's immediately obvious.
Though my favorite is "contextual"
(or maybe "contextful") so far, one other suggestion could be "integrated", as it technically has to work within a certain setup/environment.
However, "impure" (or "non-pure") has the advantage that you don't have to learn the connection between two terms.
Mildly off topic, but this made me think of a common question in the Julia forums which is "How can I write a macro to do this?" with the answer often being "you don't need to use a macro, this could be a function". Maybe if macros were called something more scary like "complex functions" it would be more obvious to beginners that they should prefer writing functions if possible :thinking:
Eli Dowling said:
I'd like to suggest "non-pure".
I don't think it really has negative connections like impure. But also it avoids the "Getting time isn't really effecting things " issue.Plus for people coming from other functional languages it's immediately obvious.
Huh. I like this actually. Being pure is like a property. Functions can fulfill the constraints and be pure, or they are not pure. So -> and => both refer to functions, but -> signify functions that are pure and => signifies a regular function, that is not pure.
a regular function, that is not pure
I'm not a fan of that connotation. In a language like roc, pure functions really should be the default. So pure functions should be considered the regular functions. Or at least some sort of even split.
I'm overall not a fan of not pure/non-pure. It really doesn't tell you the why. It just leaves things blank.
Though my favorite is "contextual"
I think "context" is too overloaded of a term in software. Everything has a context that is runs in. A web request (and lots of other code) often has an explicit context variable that is passed in. All of that is totally unrelated to effects.
That is fair.
It seems very difficult to find a great word that is not overloaded (like “contextual”), or not too inert (like “procedure”)
Yeah, probably. Likely we'll just have to pick something that fits well enough at some point. That or leave it at the status quo of effectful.
In terms of negative connotations of being "pure" versus "impure", maybe there are other terms with less connotations attached? Like "fixed" versus "unfixed", "restricted" versus "unrestricted", "hard" versus "soft", and so on.
I like "restricted" versus "unrestricted"
I would probably prefer constrained/ unconstrained, slight difference, I think constraint is a nicer word than restriction. But I actually quite like the suggestion.
Another path I really like is" deterministic"/"nondeterministic". I think that's very descriptive about what the actual issue is with impure functions.
Like if I saw that as a new user Id think "well I'd like most of my functions to be deterministic, that would make my program easier to reason about"
None of the other suggestions, even put/impure quite reach that
I really like is" deterministic"/"nondeterministic". I think that's very descriptive about what the actual issue is with impure functions.
Oh wow, yeah, that does sound really good.
I think it's very descriptive, it's just not very catchy. If "effectful" was less clunky, then we'd probably not be having this discussion. I think something simple is important to aim for
“Wild” might signal unpredictability and external influence without being negative or clunky. Balances well phonetically against “pure”, and you have the option of “tame”
I think deterministic/non-deterministic should be avoided because lots of impure functions are still deterministic.
Maybe functions being “open” and “closed” communicates it well enough? It’s succinct, and it’s pretty similar to impure/pure and unrestricted/restricted, without any negative connotations in my mind at least.
just to reiterate:
Richard Feldman said:
so I think "pure function" as one of the two terms is a very strong frontrunner, and the bar would be high for any choice other than that
I'm not saying it's impossible, but so far I don't think anything other than "pure function" has come remotely close to this bar :big_smile:
maybe a useful heuristic might be: if in the tutorial we're going to end up saying "______ functions are pure functions, we just call them something else" then a natural beginner question will be "why don't you just call them pure functions like everyone else does?"
(and to reiterate the point at the beginning of the thread, if there were already a term everyone used for "function that isn't pure" then we'd just use that and there wouldn't need to be a discussion!)
maybe another way to say what I'm thinking here: I notice we have a lot of suggestions of paired terms, where one part of the pair is not "pure function" - and I don't think that's what we're going to want here
So the objective is basically to find a synonym for “impure”, which doesn’t have negative connotations. I think calling them “open” functions is a decent term in that case. I see “open” as meaning the function has an “open door” to the outside world. It doesn’t say anything about how the function might use that access, but simply that it’s there. Though “open” still pairs better with “closed” than with “pure”, but it’s not a terrible match at least.
Richard Feldman said:
maybe another way to say what I'm thinking here: I notice we have a lot of suggestions of paired terms, where one part of the pair is not "pure function" - and I don't think that's what we're going to want here
Because of the bar placed here with "pure" being so established, I think there are two groups of solutions that could be work instead of the current null hypothesis of keeping "pure" and "effectful":
I lean towards the second group of solutions because I think concision for these kinds of concepts is really important, but maybe that's just me.
Thinking more about the “open door” metaphor, I really like the idea that, when calling such a function, you have to add the ! to actually open the metaphorical door :big_smile:
Very Kingdom Hearts, yes
Could we call an impure function an “effect”?
More succinct than “effectful”.
possible downside of conflating the actual underlying effect with the function(s) that trigger it though.
Or maybe an “activity”? I quite like the previously suggested “action” as well
Alternatively, lean into the negative connotation! Havingtainted functions sounds extremely cool :laughing:
Effectful doesn’t seem too bad to me. If a function can go from “I could do effects, but I actually just read global state,” to “now I am actually doing effects” without any change to the type signature, seems reasonable to just assume they all do effects unless we look at the definition.
The two kinds of function are "effective" and "ineffective"
So, do we have a sense of what we want to move forward with here? There are tons of good ideas, and I don't sense that any one of them is that much stronger than another, but we do have the purity inference PR in review and it has picked "pure" and "effectful" in both the compiler code and the reported error messages.
We can always change it later, but it'll be easier to do it now while we have the set of code referencing this concept localized to a single PR
I'm personally happy with pure/effectful, but thought I'd kick this can to get the feeling from others
I like pure and effectful best currently
Deterministic and non-deterministic being probably the most descriptive otherwise (but a lot longer to type).
Pure and effectful do feel like they will require the least work as they are already quite established
Okay, glad to see consensus!
+1 to "free" and "open"
What do y'all think about "loose"? (I only skimmed this thread just now; sorry if derailing.)
=> looks looser than ->; "Archers, loose your arrows!"Loose makes sense to me, and so do lots of other candidates here, but for a number of reasons described above, pure/effectful is pretty well established and would be hard to overcome
I think "it's a loose function" isn't really clear at all to what it could mean. Some other words feel like they have clear meaning as standalone, but "loose" feels too generic.
I would argue that loose is too loose a term to be using for this case ;)
What a read... I would argue the "action" (or the "action function") would be: short, descriptive, but also the word "action" (in opposite to e.g. "loose") is very common in many languages other than English.
I don't really want to open this can of worms again, buuuut I think that's one of the only pair of candidates that still would be worth considering: "functions" and "actions" are both very simple terms that are fun and mostly self-explanatory
And also they're one word each, which is a huge plus in my mind
But... I don't know how high the bar is to replace "pure" and "effectful", though I expect it's pretty high
Niclas Ahden schrieb:
It could be called a "free function" in the sense that a pure function is restricted in what it can do, while a free function can do whatever it wants. That way both terms have a word with positive connotations. No strong feelings about this, just spitballing.
"Free" could also be interpreted the opposite way pure: It's free from side effects, you can freely call it without having to worry about any side effects, it's not "attached" to the outside world through side effects.
I think action is ok for a short explainable term. Though there are a lot of non-active simple input reading and caching style functions that would be effectful.
But action vs function/calculation are pretty reasonable.
I don't mind action, but pairing it with function feels bad to me. Given every other language I know of would call both of those things functions, I feel you need a different word. Calculation isn't bad though.
Still, at this point, I think pure and effectful is fine.
I particularly like efffectful because with the purity inference changes, roc is doing effect tracking. Which is a fairly standardized term. A user can search "effectful function" or "effects" and immediately read about the underlying concepts.
I think picking standardized names for things helps us lean on existing learning resources which can aid learning and deeper understanding.
Eg: If I come from ocaml and I see roc has effectful functions I immediately understand that.
Yeah
I don't think anything beats out the ubiquity of pure. And effectful is not as ubiquitous, but it is semi-common
Actions and calculations reminds me positively of my Redux/Vue/Vuex days in 2015-16 ~ actions to change state, calculated values that update smoothly.
Perhaps presenting it like this would be friendly:
"There are two kinds of functions - calculations and actions. Calculations are pure functions... Actions are effectful functions..." so then both names act as single-word aliases for those standard-ish concepts.
It would likely spend some weirdness budget, but it's usually good to give short nicknames to top-priority concepts, and this would call attention to it being an code-impacting distinction instead of just an attribute/remark.
Tangential: Assuming the word "effectful" will be used at least somewhere in Roc's docs: As Task seemingly moves behind the scenes, would it make sense to rename it as Effect to match? Or is that name used for something behind Task already? Sorry if this is already well explained and I just need to re-read docs.
Task is fully going away
The equivalent will be effectful functions that return results
There is still the hosted module, but we will just say that it is for platforms to define their effects (or o guess actions if we use that terminology)
"Dependent function" maybe (?) because they depend on something else (usually outside of roc) to work
You can also say dependent as in "what does this function return? it depends..."
Whereas independent functions are pure functions, ones that can run on their own.
In the spirit of spending our collective brain energy on bigger issues, I'd vote to resolve this topic to discourage further bike shedding. The terms "pure" and "effectful" seem to have stuck.
Having brought up the 'action' thing, I agree. I think the bar for not saying 'pure/effectful' as the default is real high. It's more beginner-friendly to allow people to compare with concepts they'll find in other places than to have the best terminology in a vacuum. There's still a place for other terms in 2nd or 3rd party docs & explainers, but the default terms in the main docs should be searchable.
Luke Boswell has marked this topic as resolved.
Last updated: Jun 16 2026 at 16:19 UTC