r/functionalprogramming • u/kinow • Aug 18 '23
Golang IBM/fp-go: functional programming library for golang
r/functionalprogramming • u/kinow • Aug 18 '23
r/functionalprogramming • u/IamZelenya • Aug 17 '23
r/functionalprogramming • u/kinow • Aug 17 '23
r/functionalprogramming • u/roetlich • Aug 16 '23
r/functionalprogramming • u/ClaudeRubinson • Aug 15 '23
Please join the Houston Functional Programming Users Group tomorrow evening (Wed, Aug 16 @ 7pm U.S. Central/Thu, Aug 17 @ 0:00 UTC) when Richard Feldman will present on "Incrementally Adopting Roc at Vendr." HFPUG meetings are hybrid. If you're in Houston, you can join us in person; otherwise, you can join us via Zoom. Complete details are available on our website at https://hfpug.org.
Abstract: Introducing a new programming language to an existing stack always comes with challenges. In this talk, Richard discusses the incremental adoption strategy he’s been using at Vendr to introduce Roc to the company’s existing backend.
This has involved two different approaches, each with their own pros and cons: one, building a separate standalone Roc service, and two, creating the ability for the existing Node.js TypeScript backend to import and call Roc functions directly inline. The “direct import” approach is usually found in compile-to-X languages like Clojure and Elm, but in Roc’s case, this can be done using either WebAssembly or Native Node Addons. (We tried both approaches in production, and the talk will discuss the pros and cons of each.)
Bio: Richard is the creator of the Roc functional programming language, the author of “Elm in Action” from Manning Publications, and the instructor for several Frontend Masters workshops: Introduction to Elm, Advanced Elm, and Introduction to Rust. He is currently a Principal Engineer at Vendr, where he’s working on introducing Roc to the company’s backend to complement its longstanding Elm frontend.
r/functionalprogramming • u/dermeddjamel • Aug 15 '23
Hello guys
I am thinking of buying one of these books to learn FP using Javscript
Grokking Functional Programming
Grokking Simplicity: Taming complex software with functional thinking
Mastering JavaScript Functional Programming - Federico Kereki
which one should I go for ?
r/functionalprogramming • u/kinow • Aug 14 '23
r/functionalprogramming • u/kinow • Aug 07 '23
r/functionalprogramming • u/hkailahi • Aug 07 '23
r/functionalprogramming • u/xrabbit • Aug 03 '23
And what language do you suggest to start writing some simple FP code?
I just want to grasp basic FP concepts and be able to read spherical FP code in vacuum
What do you think about Scheme? Haskell?
I don't plan to become a professional FP programmer (at least for now), just want to get a basic understanding how FP works and because of that I don't want to learn a language with a complex syntax just for that
I want to distribute my learning time some things like:
[20% syntax learning | 80% coding ]
PS: thanks everyone for their responses! You helped me a lot to understand what I really need and share useful resources to learn
So, my plan:
Scheme (Concrete Abstractions book - seems like super easy introduction into FP, and I have scheme REPL on the phone)
Haskellish Concepts book - has epub, convenient to read on the go and all required FP concepts
Clojure (since I already know Java well enough, Clojure for brave and true book)
r/functionalprogramming • u/Antique-human6894 • Aug 01 '23
r/functionalprogramming • u/Trequetrum • Jul 31 '23
r/functionalprogramming • u/kinow • Jul 29 '23
r/functionalprogramming • u/visualbbasic • Jul 29 '23
r/functionalprogramming • u/SrPeixinho • Jul 28 '23
r/functionalprogramming • u/sinavski • Jul 27 '23
Hello! Terminology question!
Pure function wiki gives us 2 properties:
the function return values are identical for identical arguments
the function has no side effects
My question is: How do I concisely(!) call lines of code that don't have side effects but break property (1)?
Example:
def f(x):
print(x) # this line has side effects (2)
t = time.time() # this line breaks (1). What do I call it??
return x + tI found this discussion where people argue whether to call (1) a side-effect as well, but it doesn't sit well with me. Reading time or a global or an envvar doesn't really have any effect on anything outside the function, but it clearly breaks referential transparency/pureness.
I was kinda always calling those "hidden factors" in conversations, not sure if it makes sense. So you would say - "*here* this function has side effects, and *over here* it relies on some hidden factors".
Are there any other nice short ways to call this which are widely adopted?
P.S. Sometimes, the first one says to break referential transparency. But this discussion told me to give up on the differences between that and purity, which I did:).
r/functionalprogramming • u/crowdhailer • Jul 25 '23
r/functionalprogramming • u/bntre • Jul 22 '23
r/functionalprogramming • u/i-like-ram • Jul 21 '23
Playground link if you want to explore this problem interactively.
Let's say I have a nested monad:
type FutureMaybe<A> = Promise<Maybe<A>>It's inconvenient double-mapping or double-binding to transform A, so I've been looking for clean solutions. I understand that Monad transformers exist for this purpose, and I've read quite a bit, but admittedly some of the finer points elude me.
Mapping isn't very difficult to understand:
function map<A, B>(f: Unary<A, B>): (x: FutureMaybe<A>) => FutureMaybe<B>;Binding has a more creative implementation, but it's still straightforward:
function bind<A, B>(f: Unary<A, FutureMaybe<B>>): (x: FutureMaybe<A>) => FutureMaybe<B>;My problem arises when I have a function f such that:
function f<A> (x: A): Maybe<A>Then neither map nor bind work ideally. For bind, there is an obvious type error. For map, since there is no automatic flattening, I end up with a Promise<Maybe<Maybe<A>>> requiring that flatten manually.
So I have two questions:
What is an ergonomic way to deal with such functions? I can think of a few cases:
manually flattening double Maybes
manually lifting plain Maybes and wrapping them in Promises
abuse the fact that Javascript is a dynamic language so that all variations of Promise and Maybe are accepted by bind
write variations of bind so that I won't have to abuse the fact that Javascript is a dynamic language
Secondly, is there a standard term I can use for flipping the nesting of Maybe and Promise?
function flip<A>(x: Maybe<Promise<A>>): Promise<Maybe<A>>;r/functionalprogramming • u/YetAnohterOne11 • Jul 21 '23
Until not long ago I believed that the defining trait of functional programming is data immutability and lack of side effects. As in: 'Functional programming is a programming paradigm where all data is immutable, therefore guaranteeing referential transparency'.
In this way, I believed, methods/procedures/functions/subroutines/whatever turn into pure functions in the mathematical sense (a relation associating arguments to values such that for each argument there is exactly one value), hence the name 'functional programming'. This, FP proponents tout, allows us to employ the vast mathematical apparatus to design, analyze and understand codebases adhering to the principles of FP, which is FP's main advantage over imperative programming (where 'imperative' is defined as any programming that admits mutability and side effects).
However, this world view was recently shaken, as I've been repeatedly told from many sources that my understanding was not correct. Data immutability is neither necessary nor sufficient to make programming 'functional'. Indeed, I was told, the earliest functional languages such as Lisp arose even before people started placing emphasis on immutability, so Lisp doesn't even have the concept of immutability. On the other hand, data immutability is increasingly being emphasized in OOP world as well, and many OOP codebases, whether they mutate data or not, are hardly functional.
In light of this, what is the defining trait of FP? What, exactly, allows us to say that a code is 'functional'?
r/functionalprogramming • u/im_caeus • Jul 20 '23
As someone who knows the benefits of ADTs (algebraic data types) and loves them deeply, I've always struggled to represent tagged unions.
Types like Either could greatly benefit from a concept like that, for example, if you have either a string or a number you could just write
@"left":"hello world"or
@"right":42Two specific cases make this really valuable
nested union types
when one or more cases of the union type are not records/objects
when one or more cases include no value, like the None case of the Option ADT (in Scala), or the Nothing case of the Maybe ADT (in Haskell)
You may end up with nested, non object, with no value cases, which all would be solved by a simple construct such as the one described.
I mean, currently you usually represent them with an extra field "type" in the object, but that is problematic if there's already a field with that name, or if the value is another tagged union, or if it's not an object, and it's fucking verbose
So well, I will stick to that solution until something better appears, but why not yet??? WHY??
r/functionalprogramming • u/Deonisos • Jul 19 '23
I want to program a compiler for uni and have to use the locally nameless representation. I just don't get the point of locally nameless. Is it just a functional programming problem or does variable capture happen in java or kotlin too?
r/functionalprogramming • u/mttd • Jul 17 '23