Skip to main content

Get the Reddit app

Scan this QR code to download the app now
Or check it out in the app stores
r/functionalprogramming icon
r/functionalprogramming icon

r/functionalprogramming

members
online

fp-ts App Seeking Founding Engineer to Solve Loneliness and Polarization fp-ts App Seeking Founding Engineer to Solve Loneliness and Polarization
Jobs

At Krew Social, we are solving the $154 billion loneliness epidemic in a natural way that people crave. Our mission is to unite communities through the most intuitive friend-making app ever created. We specialize in building strong social networks within various organizations, including corporations, universities, apartment buildings, coworking spaces, and churches. Research has shown the significant benefits of fostering friendships within organizations, including improved retention rates, increased productivity, and higher customer satisfaction.

We use fp-ts/functional programming, React Native, Expo, GCP, Node.js, and are looking for a part-time Founding Engineer. If you're interested, apply on LinkedIn, and DM me a blurb about yourself and your resume. We monetize with enterprise SaaS for boosting engagement and retention at organizations.

https://www.linkedin.com/jobs/view/3946326574


Are there any technical benefits of point free programming? Are there any technical benefits of point free programming?
Question

I usually think of writing point free functions as a way to keep thinking conceptually about a program as the combination of smaller functions. There are definitely situations where it can make code more readable and times where it makes things more complicated.

Lately I've been wondering though if there's any situation where point free functions would offer any significant technical advantage or disadvantage?




SMLL gets a package manager + a package registry. SMLL gets a package manager + a package registry.
FP

SMLL v0.5.1

Months ago I posted smll and it was at its early stage. SMLL is small functional programming language created to target the JVM and the web through transpiling to JS. I created the language with the intention of learning more about compiler design as I'm a computer science undergraduate.

Months later I have successfully implemented the package manager (WIP) for the language and it is built in with the compiler. The compiler is just a simple executable that can do a lot. The package manager uses github for hosting the source code of the packages but to collectively list them I created a small website that acts as a package registry for the language.

The package manager is inspired by the golang package manager as it is invoked through the go compiler itself. Having the package manager allowed me to purge the builtin standard library and decentralize the code, hence making the project a little bit smaller.

Packages that are already live and working as they should include:

  • MLIo - for functions like println and readString

  • Adt - for Algebraic data types such as Option and Result

  • Core - for functions such as panic and exit

  • Iter - for functions that allow iterations (WIP)

  • List - defines functions for list manipulation

  • Math - defines mathematical functions such as min and max (WIP)

  • Raylib - the official bindings of the raylib library

  • More packages are available but most are WIP since I'm implementing everything.

SMLL: https://github.com/hexaredecimal/ML

REGISTRY: https://smllregistry.github.io


What is this called? What is this called?
Question

Hey guys!! My first time here! I am not a hardcore functional programmer, but lately I've been experimenting with the idea of using functions to represent a value that depends on another value. Although this might already be what a function means to you functional bros but it's still a new and exciting idea to me.

Say I need to conditionally display a text that has multiple translations stored in some resource files in the following code example:

import translate from '~/translate';

function getText(status) {
  switch (status) {
    case 'ready':
      return translate => translate('status-ready');
    case 'loading':
      return _ => '';
    case 'error':
      return translate => translate('status-error');
  }
}

getText('ready')(translate)

In this case the returned text depends on a resource and therefore a function of resource (translate) is returned. Instead of putting the responsibility of translating inside the function, it's delegated to the caller. It feels pretty logical to me.

Is this like a thing? Is there a name for this? Like using function as an abstract value. And is there any advantage to doing this instead of doing the above?

function getText(status, translate) {
  ...
}





Why some people claim FP and OOP cannot be combined? Why some people claim FP and OOP cannot be combined?
Question
// FP mixed with OOP (immutable)

add == [add] op fail ° 'add,id   // method-selector
--> ( )
queue == .. { list   // head,tail,etc
              [add]==(top°[0]) obj (pop°[0])++[1], }   // class
--> ( )
stack == .. { list   // head,tail,etc
              [add]==(top°[0]) obj [1],pop°[0] }   // class
--> ( )
(10;20;30;40;) add 50
--> ([fail] _error "Fail" ; (add ; (10 ; 20 ; 30 ; 40 ;) ; 50 ;) ;)

(queue::10;20;30;40;) add 50                   //  ::  <=> object-type
--> (queue :: 10 ; 20 ; 30 ; 40 ; 50 ;)
head°(queue :: 10 ; 20 ; 30 ; 40 ; 50 ;)
--> 10

(stack::10;20;30;40;) add 50
--> (stack :: 50 ; 10 ; 20 ; 30 ; 40 ;)
head°(stack :: 50 ; 10 ; 20 ; 30 ; 40 ;)
--> 50

// FP and OOP with immutable data are not a contradiction !

Pointfrip


Why do we love the lambda calculus? Why do we love the lambda calculus?
λ Calculus

I've been reading about some of the more esoteric models of computation lately, and it got me wondering why it is that the lambda calculus is the "default". So much literature has been built up around it now that it's hard to imagine anything different.

Is it merely the fact that the lambda calculus was the 'first to market'? Or does it have properties that make it obviously preferable to other models of computation such as combinators, interaction nets, kahn process networks, etc?

upvotes · comments



"Like buses: you wait two thousand years for a definition of “effectively calculable”, and then three come along at once." - Phil Wadler. What about Schönfinkel? "Like buses: you wait two thousand years for a definition of “effectively calculable”, and then three come along at once." - Phil Wadler. What about Schönfinkel?
Question

Hi everyone, I've a question I wanted to get your thoughts on and this subreddit felt like the most appropriate.

So Phil Wadler has this humourous, yet interesting quote that I've came across a few times in his writings and talks.

Like buses: you wait two thousand years for a definition of “effectively calculable”, and then three come along at once. The three were lambda calculus, published 1936 by Alonzo Church, recursive functions, proposed by Godel at lectures in Princeton in 1934 and published 1936 by Stephen Kleene, and Turing machines, published 1937 by Alan Turing.

- Phil Wadler, "Propositions as Types".

From what I understand, Moses Schönfinkel in his 1924 paper "On the Building Blocks of Mathematical Logic" described a formalism for universal computation by introducing (what's now known as) the S and K combinators.

Intuition tells me that Wadler is probably at least somewhat familiar with his work, but I don't want to make too much of an assumption about what he does or doesn't know.

My questions can probably be distilled to something like: do you think it's reasonable Schönfinkel is excluded from the quote?. Should he be included with the likes of Turing, Church and Godel for his early work on logic? And if you're feeling speculatory, why do you think Wadler didn't include him in the quote?



Andy Chu, "Oils for Functional Programmers" (5/15 @ 7pm central/0:00 UTC) Andy Chu, "Oils for Functional Programmers" (5/15 @ 7pm central/0:00 UTC)
Meetup

Please join the Houston Functional Programming User Group on Wednesday 5/15 at 7pm central (0:00 UTC) when Andy Chu will presenting on Oils, a new Unix shell, which he vastly undersells as "our upgrade path from bash."

I know that it sounds crazy: bash is solid, if cranky; there's zsh for those who want more customization and fish for those who want something simple.  But Andy's done some really impressive work here, trying to bring sanity to shell scripting, which of course includes embracing functional paradigms ;-)

For those in the Houston area, please join us in person at Improving. Everybody else can join us online. As always, details are available on our website at https://hfpug.org



Looking for the name or article about this functional programming pattern Looking for the name or article about this functional programming pattern
Question

Hello,

There is a programming technique that I use occasionally in my own programming, and I'm wondering whether anyone knows the name, and whether there are any articles/essays written about its use.

Here is the set up:

I have a typed tree datastructure that represents my source-of-truth. There is care put into ensuring this datastructure is clean, and to avoid redundancy. Here is an example of a basic tree of circles, with some made-up notation.

class CircleWorld {
  List<Shape> shapes;
  List<Style> styles;
}

class Circle <: Shape {
  ID id;
  double x;
  double y;
  double radius;
  ID style;
}

class UnionedShapes <: Shape {
  List<Shape> shapes;
}

class TranslatedShape <: Shape {
  Shape shape;
  double dx;
  double dy;
}

class Style {
  ID id;
  Color color;
  boolean is_opaque;
}

Here are some observations about this raw datastructure:

  • To compute the absolute coordinates of a Circle, you need the entire chain of TranslatedShape that lead up to it.

  • To look up the color of a Circle, you need to retrieve the corresponding Style object given its id.

  • Given only a Circle object, you can't retrieve either its absolute coordinates or its color, you also need the CircleWorld object.

For an object-oriented programmer, it is normal to expect to be able to query all sorts of useful information about an object given just its handle. For example:

  • Given a Circle, you can directly look up its absolute coordinates and color.

  • Given a Style, you can directly look up all the circles with this style.

  • etc.

So I can use a simple preprocessing algorithm to convert a CircleWorld datastructure into a ViewOfCircleWorld datastructure, where I can easily query for information given just an object handle. The two main advantages that I gain from this technique is that:

  • I expose an API that is easy and familiar to object-oriented programmers.

  • All the small "algorithms" for interpreting the raw datastructure, e.g. for looking up the color of a circle, are consolidated into one central place, so there's less need for each individual programmer to understand the structure of the raw datastructure.

So, here's my questions:

  • Does this technique have a name?

  • Does anyone else encounter similar problems, and have other ways of approaching it?

Thanks very much!




Slides of my talk "Functional Programming: Failed Successfully: Slides of my talk "Functional Programming: Failed Successfully:
FP

Hi folks, yesterday I presented a talk "Functional Programming: Failed Successfully" at u/lambda_conf.

This is an important talk to me about the subject that bothers me a lot in the past several years. Enjoyed speaking about it. Will be waiting for the video; here are the slides anyway:

https://docs.google.com/presentation/d/10XX_g1pIWcVyH74M_pfwcXunCf8yMKhsk481aVqzEvY/edit?usp=sharing


Immutable data structures and efficiency: what am I missing? Immutable data structures and efficiency: what am I missing?
Question

Hello everyone! I've recently been playing around with functional programming languages (mostly lisp specifically), and I came to an interesting (I think) realization, and I want to know if I am right or if I'm missing something.

Data structures in imperative languages are normally stored in contiguous memory. This makes both access and modification O(1), but copying is O(n). But for non-contiguous memory such as linked lists, copying is O(1), but access of arbitrary elements (meaning elements other than the beginning or end) is O(n). Is it impossible to have an array-like data structure that can be copied AND accessed in constant time? If so, is immutable state therefore inherently inefficient whenever arbitrary element access is required (because either copying or access is O(n))?

I'm not trying to dunk on anyone, I'm actually curious. I have heard that imperative programming can always be more efficient than functional programming, with the tradeoff being ergonomics and safety. I'm wondering if this is what people are referring to when they say that.


FP is easy to understand than oop for me FP is easy to understand than oop for me
OO and FP

I tried multiple oop paradigm languages like java,c#, python but I didn't get the concept properly read many books,blogs and tried many yt videos but I felt something missing . It's not the problem of I don't like coding but it's about understanding the concept but when I tried Fp more specifically elixir ,I don't know but this is something that I'm searching for these many days. Finally I found my language but everyone close to me started saying, you need a oop language to get a job. In reality it's true there is only few job openings for fp devs and that is only for senior devs. What is the better choice stick with Fp or learn oop language or should I quit programming (but I love to build products)