#functional_programming

posts tagged #functional_programming

0

Blog - Shared Postgres Test Container with Expecto in FSharp

Programming Shared Postgres Test Container with Expecto in FSharp blog.keyboardvagabond.com
preview

I’m learning FSharp by creating a web application. I’ve cycled through lots of different ways of doing things, libraries, etc. Today I finally got my integration tests to use a single docker test contaner with the Expecto test framework. I couldn’t find a good example online of how to do it, so I’m sharing it here.

I’m learning FSharp by creating a web application. I’ve cycled through lots of different ways of doing things, libraries, etc. Today I finally got my integration tests to use a single docker test contaner with the Expecto test framework. I couldn’t find a good example online of how to do it, so I’m sharing it here.

0

Navigating and Learning Data Access in FSharp

Programming Navigating and Learning Data Access in FSharp blog.keyboardvagabond.com
preview

I wrote a blog post about me getting in to FSharp web application development, but am having issues deciding how I want the data access to look. I’m very much open to feedback!

I wrote a blog post about me getting in to FSharp web application development, but am having issues deciding how I want the data access to look. I’m very much open to feedback!

0

I've created a port of a functional utility library to python

preview

cross-posted from: programming.dev/post/46518217

Links:

I created it mainly as a proof of concept that python’s typing system is mature enough to support such a thing. The process was fun and I was able to help make remeda.js docs a bit better

The library is as typed as possible with my knowledge of python typing system, which means dict typing is kinda meh, but for iterables it is as good as in TS.

I decided to publish 1.X, since I’ve been adding a lot of stuff that “absolutely must be in 1.X” and got tired of the scope creep, so there is a bunch of TODOs, but they are "nice to have"s.

I’m planning to work on the TODOs and making the docs better now that I’ve managed to release it.

About the library:

It supports what remeda.js calls “data-first” and “data-last” approaches to calling functions. That means:

x = R.map([1, 2, 3], lambda i: i +1)
# is the same as
x = R.map(lambda i: i +1)([1, 2, 3])

which allows for a “fun” function composition:

import remedapy as R

R.pipe(
    [1, 2, 2, 3, 3, 4, 5, 6],
    R.for_each(print),
    R.unique(),
    R.take(3),
    list
)
# Returns [1, 2, 3]
# Prints:
# 1
# 2
# 2
# 3

Features:

  • as typed as possible, checked with basedpyright
  • 100% code coverage, but the tests could be a bit more exhaustive
  • docstrings for everything (they might require some work)
  • no AI, 100% Human Stupidity

cross-posted from: programming.dev/post/46518217

Links:

I created it mainly as a proof of concept that python’s typing system is mature enough to support such a thing. The process was fun and I was able to help make remeda.js docs a bit better

The library is as typed as possible with my knowledge of python typing system, which means dict typing is kinda meh, but for iterables it is as good as in TS.

I decided to publish 1.X, since I’ve been adding a lot of stuff that “absolutely must be in 1.X” and got tired of the scope creep, so there is a bunch of TODOs, but they are "nice to have"s.

I’m planning to work on the TODOs and making the docs better now that I’ve managed to release it.

About the library:

It supports what remeda.js calls “data-first” and “data-last” approaches to calling functions. That means:

x = R.map([1, 2, 3], lambda i: i +1)
# is the same as
x = R.map(lambda i: i +1)([1, 2, 3])

which allows for a “fun” function composition:

import remedapy as R

R.pipe(
    [1, 2, 2, 3, 3, 4, 5, 6],
    R.for_each(print),
    R.unique(),
    R.take(3),
    list
)
# Returns [1, 2, 3]
# Prints:
# 1
# 2
# 2
# 3

Features:

  • as typed as possible, checked with basedpyright
  • 100% code coverage, but the tests could be a bit more exhaustive
  • docstrings for everything (they might require some work)
  • no AI, 100% Human Stupidity
0

I'm getting started with functional programming, which language would you recommend?

preview

cross-posted from: gregtech.eu/post/19047959

Specifically, I’m interested in BEAM, but I’m not sure if I should go for Elixir or Gleam. What seems cool about Gleam is that it has static typing.

I have no experience with functional programming at all btw

cross-posted from: gregtech.eu/post/19047959

Specifically, I’m interested in BEAM, but I’m not sure if I should go for Elixir or Gleam. What seems cool about Gleam is that it has static typing.

I have no experience with functional programming at all btw

0

What would you ask Simon Peyton Jones?

preview

What would you ask Simon Peyton Jones?


I have long aspired to interview Simon Peyton Jones, whom I consider the most articulate and charismatic figure in the functional programming community. What makes him even more remarkable is his approachability; I reached out to him on LinkedIn—thinking, why not?—and he actually responded. I was so astonished that I initially thought the reply might have come from his son, Michael, whom I occasionally encounter due to my involvement with Cardano and Plutus.

For years, I’ve dreamed of hosting a podcast where I interview my heroes, blending in crowd-sourced questions alongside my own.


I aim to pose truly insightful questions about the developmental journey of Haskell. I’m uncertain whether I need to center the interview around the publication of his most recent project, Verse, to secure his participation.

Additionally, what areas should I research heavily? I am versed in category theory and functional programming. But, I think I would need to read up on lambda calculus to sufficiently talk about it.

However, I am more inclined to delve into the profound insights he offers on deeper topics, as discussed by other equally eloquent Haskell core developers like Phil Wadler on the CoRecursive podcast. To me, some of the finest podcasting I’ve ever encountered was an episode where Phil Wadler talks about “God’s Programming Language” and reads letters between the pioneers of lambda calculus, at one point remarking that “the laws of programming languages aren’t invented; they are discovered.”

Another remarkable moment in podcasting was this whirlwind episode with John Wiegley, where he discusses some truly otherworldly research he has conducted.

What would you ask Simon Peyton Jones?


I have long aspired to interview Simon Peyton Jones, whom I consider the most articulate and charismatic figure in the functional programming community. What makes him even more remarkable is his approachability; I reached out to him on LinkedIn—thinking, why not?—and he actually responded. I was so astonished that I initially thought the reply might have come from his son, Michael, whom I occasionally encounter due to my involvement with Cardano and Plutus.

For years, I’ve dreamed of hosting a podcast where I interview my heroes, blending in crowd-sourced questions alongside my own.


I aim to pose truly insightful questions about the developmental journey of Haskell. I’m uncertain whether I need to center the interview around the publication of his most recent project, Verse, to secure his participation.

Additionally, what areas should I research heavily? I am versed in category theory and functional programming. But, I think I would need to read up on lambda calculus to sufficiently talk about it.

However, I am more inclined to delve into the profound insights he offers on deeper topics, as discussed by other equally eloquent Haskell core developers like Phil Wadler on the CoRecursive podcast. To me, some of the finest podcasting I’ve ever encountered was an episode where Phil Wadler talks about “God’s Programming Language” and reads letters between the pioneers of lambda calculus, at one point remarking that “the laws of programming languages aren’t invented; they are discovered.”

Another remarkable moment in podcasting was this whirlwind episode with John Wiegley, where he discusses some truly otherworldly research he has conducted.

0

If "category" has a better name....

preview

cross-posted from: sopuli.xyz/post/10354955

If “category” has a better name…

Isn’t it just “composite”?

Every arrow in category can be composed, the set(or class or whatnot…) of that is composite.

cross-posted from: sopuli.xyz/post/10354955

If “category” has a better name…

Isn’t it just “composite”?

Every arrow in category can be composed, the set(or class or whatnot…) of that is composite.

0

Understanding the Type of call/cc

preview

cross-posted from: sopuli.xyz/post/9969591

Understanding the Type of call/cc

He introduces but also criticizes the use of call/cc, 1. not being a function and looks like a function, 2. able to produce an union of types with it.

Is he correct? What do you think?

cross-posted from: sopuli.xyz/post/9969591

Understanding the Type of call/cc

He introduces but also criticizes the use of call/cc, 1. not being a function and looks like a function, 2. able to produce an union of types with it.

Is he correct? What do you think?

0

How to convert imperative side-effectful program to functional (in Ocaml)?

preview

I’ve been enjoying learning ocaml, but I found it very easy to write code riddled with side effects and imperative-ness.

Take this example:

let some_func arg = 
  let input = format_input_from_stdin ()
  let read_content = read_file "some/file/path.txt"
  let to_write = get_write_file_content input read_content
  let () = write_file "some/other/path.txt" to_write 
  let output = run_external_command_with_output 
  (output, read_content)

As you can see, many side effects and imperative steps in the code. Is there a better practice for coding this in a functional manner?

I’ve been enjoying learning ocaml, but I found it very easy to write code riddled with side effects and imperative-ness.

Take this example:

let some_func arg = 
  let input = format_input_from_stdin ()
  let read_content = read_file "some/file/path.txt"
  let to_write = get_write_file_content input read_content
  let () = write_file "some/other/path.txt" to_write 
  let output = run_external_command_with_output 
  (output, read_content)

As you can see, many side effects and imperative steps in the code. Is there a better practice for coding this in a functional manner?

0

Using Ocaml to learn FP. What FP concepts should I touch on?

preview

I just started to learn Ocaml to learn functional programming. I will use it to build a CLI that’s mostly orchestrating other programs.

My experience is mostly in JS / TS, but I’ve also coded a good bit in Python and Lua.

Below, I provided a list of things I learned or focused on while using OCaml. But I feel like I must be missing something. This is only moderately different from what I’m used to in JS. I expected something more radical. Moreover, I constantly hear a lot of FP jargon (like “highly kinded types”, monads, etc) that I feel am still missing.

So far, here’s what I studied:

  • immutability
  • avoid side affects
  • static typing
  • recursion instead of loops
  • option / maybe
  • higher order functions
  • conditionals and other constructs as expressions, when they’re statements in other languages
  • pipelines and functions as input —> output
  • currying
  • scoping with let

What am I missing?

I just started to learn Ocaml to learn functional programming. I will use it to build a CLI that’s mostly orchestrating other programs.

My experience is mostly in JS / TS, but I’ve also coded a good bit in Python and Lua.

Below, I provided a list of things I learned or focused on while using OCaml. But I feel like I must be missing something. This is only moderately different from what I’m used to in JS. I expected something more radical. Moreover, I constantly hear a lot of FP jargon (like “highly kinded types”, monads, etc) that I feel am still missing.

So far, here’s what I studied:

  • immutability
  • avoid side affects
  • static typing
  • recursion instead of loops
  • option / maybe
  • higher order functions
  • conditionals and other constructs as expressions, when they’re statements in other languages
  • pipelines and functions as input —> output
  • currying
  • scoping with let

What am I missing?

0

Fixing the Future | Functional Programming: The Biggest Change Since We Killed The Goto?

play · share.transistor.fm
Functional Programming: The Biggest Change Since We Killed The Goto? | Fixing the Future share.transistor.fm
preview

A podcast with transcript which may help explain fp to laymen.

A podcast with transcript which may help explain fp to laymen.

0

How did you get started with Functional Programming?

preview

Hello fellow FP-Lemmyites. I’d love to hear stories about what got you interested in FP originally, and how you learned.

Hello fellow FP-Lemmyites. I’d love to hear stories about what got you interested in FP originally, and how you learned.

0

Oxidizing OCaml: Rust-Style Ownership | Max Slater - blog.janestreet.com

preview

In part one, we discussed how OCaml’s locality mode enables safe stack allocation. In this post, we will explore additional modes for representing ownership.

blog.janestreet.com/oxidizing-ocaml-ownership/

In part one, we discussed how OCaml’s locality mode enables safe stack allocation. In this post, we will explore additional modes for representing ownership.

blog.janestreet.com/oxidizing-ocaml-ownership/

0

What do people here like better: typed or untyped functional languages?

preview

My first language was Racket and so naturally I gravitated to the lispy untyped functional programming style even when I was using languages like Python or Java, but when I tried Haskell for the first time my mind was absolutely blown and I was a convert ever since. What are your thoughts?

My first language was Racket and so naturally I gravitated to the lispy untyped functional programming style even when I was using languages like Python or Java, but when I tried Haskell for the first time my mind was absolutely blown and I was a convert ever since. What are your thoughts?

0

Does anyone here use a functional language in their day jobs?

preview

I’d love to hear more about it. I’m a new grad who’s done a bunch of internships using functional programming languages but didn’t find a new grad position that does

I’d love to hear more about it. I’m a new grad who’s done a bunch of internships using functional programming languages but didn’t find a new grad position that does

0

Excel as an intro to functional programming concepts?

preview

Howdy, I remember a podcast where they have the example of Microsoft Excel as an example for an introduction to functional programming. I believe it was an SE Radio podcast on Clojure or that build tool it uses. It doesn’t really matter.

I already understood functional concepts and try to use them where I can in Java and other languages. (It is easier to reason about immutable data and pure methods.) I found the metaphor of Excel very interesting though. Because that’s basically what it is. I’m sure there are ways to have it not act functionally but the vast majority of the time it is, and I think more people have the basic vocabulary of Excel than functional programming.

Has anyone ever used this or heard of it being used as an example while teaching fp?

Howdy, I remember a podcast where they have the example of Microsoft Excel as an example for an introduction to functional programming. I believe it was an SE Radio podcast on Clojure or that build tool it uses. It doesn’t really matter.

I already understood functional concepts and try to use them where I can in Java and other languages. (It is easier to reason about immutable data and pure methods.) I found the metaphor of Excel very interesting though. Because that’s basically what it is. I’m sure there are ways to have it not act functionally but the vast majority of the time it is, and I think more people have the basic vocabulary of Excel than functional programming.

Has anyone ever used this or heard of it being used as an example while teaching fp?

0

Rofi-Hoogle: A Tool To Search Hoogle From Your Desktop

GitHub GitHub - rebeccaskinner/rofi-hoogle: Search Hoogle from Rofi github.com
preview

Rofi-Hoogle is a tool I wrote a couple of years ago to scratch a particular itch: I was often wanting to quickly remind myself of the name or types of functions while writing, and I didn’t always want to search Hoogle or spin up a repl to figure out what I needed. I was already using rofi to quickly reference other information, so I decided to build an integration to let me reference a local hoogle DB with a single keystroke directly from my desktop.

Rofi-Hoogle is a tool I wrote a couple of years ago to scratch a particular itch: I was often wanting to quickly remind myself of the name or types of functions while writing, and I didn’t always want to search Hoogle or spin up a repl to figure out what I needed. I was already using rofi to quickly reference other information, so I decided to build an integration to let me reference a local hoogle DB with a single keystroke directly from my desktop.

0

Share some of your favorite FP Talks

preview

FP is a big umbrella with a lot of interesting work happening. Let’s help one-another stay up-to-date by sharing links of some of our favorite FP and FP-adjacent talks.

FP is a big umbrella with a lot of interesting work happening. Let’s help one-another stay up-to-date by sharing links of some of our favorite FP and FP-adjacent talks.

0

An Introduction to the Fixed Point Function

RebeccaSkinner.net The Fixed Point rebeccaskinner.net
preview

Hi everyone. I thought I’d kick off the functional programming community here by sharing an article from my own blog on Haskell’s fixed point function.

Hi everyone. I thought I’d kick off the functional programming community here by sharing an article from my own blog on Haskell’s fixed point function.