fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

10K
active users

PRMA

It's so frustrating that whenever I ask about Functional Programming-style crates in Rust, the answer I get is mostly discouragement about doing full FP in rust.

Isn't rust supposed to have FP support?

Isn't FP supposed to help your programs be simpler, regardless of how purely functional your language is?

@Amirography It's not that Rustaceans don't want you to do FP, it's that the culture dislikes any type of dogmatism or labels. Rust's success is partly because of pragmatism, and people don't want to lose that. If someone wants to do "pure" FP (or OOP for that matter), there is an immediate reaction, because no one wants Rust to be constrained by any particular mental model.

@dpom I understand the reaction. The problem is that I did not ask for pure fp. But rather a fp-style crate which may not be pure, but has a bit more than just using iteration and map in terms of FP patterns. Now if I asked for a pure fp, I get it. But I'm not sure why the immediate reaction to such a question should be discouraging fp whole together in a language with close relations to FP.

@Amirography Some of what you're experiencing may have less to do with Rust, and more to do with the backgrounds of the people giving the answer. If you're among programmers that came to Rust from systems programming in C++, for example, then their view on how to approach things is influenced by their experience before coming to Rust.

@Amirography interesting. Can you elaborate a bit about what you consider "full FP" in this case ?

It might help explain both the responses/answers and shed light on why you find it frustrating :)

@lloydmeta by that I mean pure. And let me emphasize that I'm not asking for pure. But the mention of an FP style (or the best I can get) only gets warning about pure FP. Which was not what I was asking for.

@Amirography Gotcha…and what exactly is meant by “pure FP” in this sense? I kinda have an idea, but want to make sure I’m on the same page here, since often the definition differs based on context, as well as who is reading and writing those words..

@lloydmeta Side effects-less functions up until "main" and no use of mutability.

@Amirography. It’s what I thought, given FP zeitgeist and what Rust can enable :D

While I don’t necessarily agree that you should be discouraged from “pure FP” when you ask for “FP”, I can see why ppl would warn/discourage the former, given that safe/tracked mutation is literally part of the language. You *can* wrap it but you end up paying in terms of complexity/perf.

Embracing `mut` does require some relearning for FP diehards, so maybe they wanted to be up front about it.

@lloydmeta i can see that. Though there is enough time that happened that I'm disappointed with my efforts to learn FP patterns from Rust community. I'm taking a stab at Haskell to learn the over-arching patterns.

Although I found the 'nom' crate to be one yummy cookie, it is a lower level library, and does not provide examples of how an application may push IO side effects to the edge.

@Amirography I think that’s a great call! Haskell is a great place for learning/stealing FP patterns that can then be applied in other places :)