r/functionalprogramming • • Jul 01 '22

JavaScript The best resource to learn functional programming in JavaScript

15 Upvotes

Hi folks,

As the title suggest I'm looking for resources to learn functional programming in JavaScript. All suggestions are welcome - books, courses, etc.

r/functionalprogramming • • Apr 21 '21

JavaScript FP JavaScript in the wild?

10 Upvotes

I'm looking into FP but I am only able to find snippets of code in the wild that are too focused to get even a rough idea of a real world working app. Even a little more than todo app with an Ajax somewhere would be alright, I'm not strictly looking for a full implementation. I know there are reference apps, to do apps, shopping cart apps, etc... so you can get a rough idea of Vue, React, Angular, and was thinking whether the same exists for a FP js app. Thank you for any help.

r/functionalprogramming • • Jun 26 '22

JavaScript Really good explanation of a monad in under 100 seconds

Thumbnail
youtube.com
125 Upvotes

r/functionalprogramming • • Jun 22 '21

JavaScript Imperative vs Declarative programming in JavaScript

23 Upvotes

Hi everyone, I have tried describing the difference between imperative and declarative programming. It's not the first time that I have tried and I am hoping that I am able to communicate it in a clear way but I would appreciate the feedback of the community.

Please have a look at

the Medium post: https://medium.com/weekly-webtips/imperative-vs-declarative-programming-in-javascript-25511b90cdb7

and the YouTube video: https://www.youtube.com/watch?v=oFXOLbAX4Pw

r/functionalprogramming • • Jul 31 '19

JavaScript Recommendations for JavaScript functional programming

22 Upvotes

As the title states, what do you recommend? I am fairly new to programming overall, hence the JavaScript. I have also come across Ramda.js functional programming library. Any thoughts for a newbie?

r/functionalprogramming • • Oct 13 '20

JavaScript How do I write this JS function in a immutable way ?

3 Upvotes

How do I write this javascript function in a immutable fashion?
I mean without pushing values into a array, is there a way to do it all in one function?

is there a function for this in lodash or ramda ? how would you do it ?

getTexts: async (page, handlers) => {
		let texts = [];

		handlers.map(async (handler) => {
			const text = await page.$eval(handler, (e) => e.innerText);
			texts.push(text);
		});

		return texts;
	},

r/functionalprogramming • • Jul 11 '20

JavaScript JavaScript Tagged Unions

13 Upvotes

Tagged Union implementation and some helper functions in JavaScript.

https://github.com/tariqqubti/js-tagged-union

A package to basically be able to do this:

import {Maybe, Run, Check, Http, Loading, Ok, Err} from '...';

// Each arm could be abstracted into its own function
const state = await Maybe(localStorage.getItem('userInfo')).match({ // null, undefined check
  Some: info => Run(() => JSON.parse(info)).match({ // parse json
    Ok: info => Check(info.id, x => /valid/.test(x)).match({ // run validation
      Pass: async id => (await Http(fetch(`/user/${id}`))).match({ // fetch
        Success: res => Ok(res.data), // res.status === 200
        NotFound: res => Err(Error(res.data)), // res.status === 404
        Err: err => Err(err), // timeout, disconnection, etc.
      }),
      Fail: () => Err(Error('Invalid stored user info')),
    })
    Err: () => Err(Error('Could not parse user info')),
  })
  None: () => Err(Error('Stored user info was not found'))
});