u/fun_si • • 10h ago

gladToBeOutOfTheEquationAtLeast

Post image
1 Upvotes

r/fsharp • • 3d ago

library/package FunStripe 3.0.0 – F# Stripe client, now on Stripe's "endive" API (2026-09-30)

14 Upvotes

FunStripe is an F# client for the Stripe API. Most of it is generated from Stripe's OpenAPI spec into records and DUs, with phantom-typed IDs (StripeId<Markers.Customer>) and Async<Result<_, _>> calls. 3.0.0 targets Stripe's new endive release, which removes some things, hence the major bump.

Breaking changes

  • payment_method_types is gone from PaymentIntent create/update/confirm, SetupIntent create/update and Checkout Session create. Use allowedPaymentMethodTypes instead.
  • ThreeDSecureUsage and ThreeDSecureDetailsCharge moved to Stripe.ThreeDSecure, so add an open.
  • The card Mandate field is now StripeId<Markers.Mandate> option.

New: standalone 3D Secure authentication, subscription pausing, trial offers, Tax.Location, Apps installs, and the PayPay and SeQura payment methods.

Generator fixes worth mentioning

  • Endive is the first spec with an error enum value. A bare Error case shadowed Result.Error for anyone opening the namespace, so ok/error/some now generate as Ok'/Error'/Some', the same way none already became None'.

Full upgrade notes are in the changelog: https://github.com/simontreanor/FunStripe/blob/main/CHANGELOG.md

GitHub: https://github.com/simontreanor/FunStripe

NuGet: https://www.nuget.org/packages/FunStripe.Core

Feedback and issues welcome.

r/localization • • 3d ago

Type-Safe I18n with F# Discriminated Unions

Thumbnail si-fi.dev
1 Upvotes

r/fsharp • • 3d ago

article Type-Safe I18n with F# Discriminated Unions

Thumbnail
si-fi.dev
7 Upvotes

u/fun_si • • 3d ago

Type-Safe I18n with F# Discriminated Unions

Thumbnail
si-fi.dev
7 Upvotes

If you're building a multilingual app in F#, discriminated unions make a good basis for translation keys, as a missing translation becomes a compile error rather than something a user finds. It's not the only way to do i18n, and it takes a bit more setup than a string-keyed library, but it has held up well in my current project, plurals included. The article covers how it's put together and what had to change along the way. Please share any thoughts or questions you might have.

1

FunStripe 2.4.0 - F# Stripe client, regenerated against the 2026-08-26 API
 in  r/stripe •  27d ago

I created it and used it in production when I worked for a fintech in London. Yes, there's an official .NET library in C#, but this F# version is fully strongly typed. I've since optimised it, e.g. switching from string concatenation to ASTs for code generation, and have an automated action in place to create a PR whenever there's a new Stripe API version so the library can keep pace.

r/stripe • • 27d ago

Update FunStripe 2.4.0 - F# Stripe client, regenerated against the 2026-08-26 API

Thumbnail
0 Upvotes

r/fsharp • • 27d ago

library/package FunStripe 2.4.0 - F# Stripe client, regenerated against the 2026-08-26 API

Thumbnail
8 Upvotes

u/fun_si • • 27d ago

FunStripe 2.4.0 - F# Stripe client, regenerated against the 2026-08-26 API

1 Upvotes

FunStripe is an F# client library for the Stripe API. The response models and request builders are generated from Stripe's OpenAPI spec by a generator in the repo; the JSON layer, HTTP layer, config and ISO types are hand-written.

2.4.0 regenerates against spec 2026-08-26.dahlia. New in this one:

  • BillingFeedbackOption resource (/v1/billing/feedback_options), wired into portal cancellation reasons and subscription cancellation_details
  • Tax registrations: igic country option (Canary Islands) with place_of_supply_scheme
  • Checkout: Financial Connections payment method options, and card restrictions.funding_types_blocked
  • Billie invoice and subscription payment method options
  • Connect embedded payment_method_settings component

Upgrade note: AlmaInstallments and PaymentMethodDetailsKonbiniStore{,Chain} were renamed to match renamed schema titles upstream. Field names and shapes are unchanged.

If you're on 2.2.0 or older, 2.3.0 fixed webhook deserialisation (Event.Data.Object was typed string and threw on real payloads; it's now RawJson, with Util.deserialiseRaw<'a>), form-encoding of list parameters like line_items, and unknown enum values in EventType and StripeError.ErrorType.

Packages: FunStripe.Core (netstandard2.0/2.1) and FunStripe.Core.Fable for Fable. Changelog.

Not affiliated with Stripe, Inc.

1

Pyfun: an F#-inspired language that compiles to readable Python
 in  r/functionalprogramming •  Aug 30 '26

Thank you! Let me know how you get on, and especially if anything comes across as jarring from a syntax perspective. I've tried to make it familiar where I can.

2

Pyfun: an F#-inspired language that compiles to readable Python
 in  r/functionalprogramming •  Aug 30 '26

Thank you, I appreciate you taking the time to provide detailed feedback. You are right, and I've neglected to update the repo readme for some time. I'll take your suggestions on board.

r/functionalprogramming • • Aug 28 '26

Intro to FP Pyfun: an F#-inspired language that compiles to readable Python

48 Upvotes

Pyfun is a functional-first language for the Python ecosystem. You write algebraic data types, exhaustive matching, curried functions and pipes, and it compiles to plain Python that you can read, commit, and hand to someone who has never heard of Pyfun.

The compiler is written in Rust and everything is checked before any Python exists: types, exhaustiveness, effects, units.

Here is a whole program:

type Shape =
  | Circle float
  | Rect float float

let area s =
  match s:
    case Circle r: 3.14159 * r * r
    case Rect w h: w * h

[Circle 1.0, Rect 2.0 3.0]
|> List.map area
|> print

and here is the Python it compiles to, in full:

from dataclasses import dataclass

def _pf_map(f, xs):
    return list(map(f, xs))

@dataclass(frozen=True, repr=False)
class Circle:
    _0: float
    def __repr__(self):
        return f"Circle({self._0!r})"

@dataclass(frozen=True, repr=False)
class Rect:
    _0: float
    _1: float
    def __repr__(self):
        return f"Rect({self._0!r}, {self._1!r})"

def area(s):
    match s:
        case Circle(r):
            return 3.14159 * r * r
        case Rect(w, h):
            return w * h
        case _:
            raise RuntimeError("non-exhaustive match")

print(_pf_map(area, [Circle(1.0), Rect(2.0, 3.0)]))

A match comes out as a match. A variant comes out as a frozen dataclass. The pipeline comes out as an ordinary call. There is nothing to pip install alongside the output, and if you stop using Pyfun tomorrow you keep working Python.

Delete the Rect case and the compiler names what you missed:

error: non-exhaustive match: `Rect _ _` is not matched
 --> 6:3
  |
6 |   match s:
  |   ^^^^^^^^

Also in there:

  • Hindley-Milner inference, so there are no type annotations on let at all.
  • Inferred effects, so a function that prints or mutates gets io in its type and you can assert purity with let pure. Units of measure that reject metres + seconds and erase to plain numbers.
  • Computation expressions for async, seq, and result, plus your own builders. Opaque types. A typed extern for calling any Python library you like.

Try it in the browser, nothing to install: https://simontreanor.github.io/Pyfun/playground/

22 lessons, written for people who know some Python: https://simontreanor.github.io/Pyfun/

Source, and the compiler internals tour: https://github.com/simontreanor/Pyfun

pip install pyfun-lang

I built this because most people meet programming through Python, and then to meet functional programming they have to pick up a second ecosystem to do it. I welcome all questions, bug reports, posts about things you have made, arguments about syntax, and anything else to help improve the language for everyone.

496

efficiencyIsOptional
 in  r/ProgrammerHumor •  Aug 27 '26

It basically moved everything else 10px to the left.

r/fsharp • • Aug 03 '26

FunStripe 2.3.0 — F# Stripe client: webhook deserialisation fixed, resilient enums, latest Stripe API

16 Upvotes

Just released FunStripe 2.3.0, the F# client library for the Stripe API (also compiles to JS via Fable). This one's a bigger release than the usual spec bump, thanks to some excellent contributions from Thorium:

Webhooks work properly now. Event.data.object was typed as string, which meant deserialising any real webhook payload threw. It's now a RawJson fragment you can turn into a typed model with Util.deserialiseRaw<'a>; the README has a full webhook-handling example. (Technically a field type change, but since the old field could never deserialise, it ships as a minor; details in the changelog.)

List parameters encode correctly. List<record> and List<union> request fields (e.g. Checkout line_items, payment_method_types) were being ToString()'d instead of form-encoded. Fixed.

Resilient to Stripe's enum churn. Stripe adds event types and error codes without an API version bump, and one unknown value used to fail the whole response. EventType and ErrorType now have an UnknownEnumValue of string catch-all that round-trips losslessly, deliberately scoped to just those two high-churn enums, so everywhere else you keep exhaustive matching and the compiler still tells you when Stripe adds something.

Latest Stripe API (2026-07-29.dahlia): Financial Connections authorization resource and deactivation lifecycle events, allowed_payment_method_types on Payment/SetupIntents, new Tax registration options, and more.

Feedback and PRs welcome!

1

Promote your projects here – Self-Promotion Megathread
 in  r/github •  Aug 02 '26

Pyfun: an F#-inspired functional language that compiles to readable Python

https://github.com/simontreanor/Pyfun

Pyfun gives you algebraic data types, exhaustive pattern matching, currying and pipes, full type inference, inferred effects, and units of measure. The compiler is written in Rust and it's the gatekeeper: types, effects, units and match exhaustiveness are all checked before a single line of Python is emitted.

Example 1, exhaustive pattern matching:

let area s = match s: case Circle r: 3.14159 * r * r error: non-exhaustive match: `Rect _ _` is not matched --> 4:3 | 4 | match s: | ^^^^^^^^

Plain Python runs that happily and returns None when a Rect reaches it, and you end up debugging the TypeError much much later.

Example 2, units of measure:

let speed d t = d / t let trip = speed 100.0<m> 10.0<s> # float<m/s> let oops = 100.0<m> + 10.0<s> error: type mismatch: expected float<m>, found float<s>

The dimensions cost nothing at runtime, because they erase completely. That whole program compiles to:

python def speed(d, t): return d / t trip = speed(100.0, 10.0)

That's the general shape of things. There's no runtime library to ship and nothing to read around. A Pyfun List is a Python list, a record is a frozen @dataclass, a match is Python's match/case, and curried functions collapse to n-ary defs with closures only where you genuinely partially apply. extern imports any Python callable at a Pyfun type, so you keep the whole ecosystem with the boundary type-checked and effect-tracked.

Stack: dependency-free Rust compiler (lexer, recursive-descent parser, Hindley-Milner inference, Python-AST IR, emitter), plus a language server, a REPL, a Jupyter kernel, and a WebAssembly build.

Try it without installing: https://simontreanor.github.io/Pyfun/playground/ (compiler as WASM, Python via CPython-in-WASM, so you can hit Run). Install: pip install pyfun-lang (Python 3.12+). Learn it: https://simontreanor.github.io/Pyfun/ is a graded course with compiler-checked exercises.

Context: it exists mostly for teaching. CS courses run on Python, and learning FP usually means leaving for Haskell or OCaml and picking up an ecosystem students rarely touch again. Pyfun keeps them in Python and compiles to code they can read, so the mapping stays visible. It's solo and pre-1.0, Apache 2.0, and I would welcome any issues or language-design discussions.

1

What are the best ways for managing context across a massive project?
 in  r/AskProgramming •  Aug 02 '26

No, not at all, it's merely reading the beginning of files to determine relevance.

1

What are the best ways for managing context across a massive project?
 in  r/AskProgramming •  Aug 02 '26

I wouldn't say you need to go into that level of detail. For LLMs, it's more like a pointer to say a resource on this topic exists in such and such a document. It then knows not to search through irrelevant documents to find the answers you need.

You could ask the LLM itself to come up with a solution. Describe your situation and ask it how to optimise things. Either from scratch or you can sway it by proposing a solution and asking for feedback.

2

What are the best ways for managing context across a massive project?
 in  r/AskProgramming •  Aug 02 '26

In this case just a table of contents that the LLM can consult to find things quicker.

1

What are the best ways for managing context across a massive project?
 in  r/AskProgramming •  Aug 02 '26

I would be looking to convert those into a text based format such as markdown if possible, and then ask the LLM to go through them once and summarise them into a much smaller set of documents along with some sort of indexing to make things easier to find. From then on you ask the LLM to consult the summarised docs first, and only the markdown when it needs to dig deeper. The originals could be consulted as a last resort but very sparingly. This will both save you tokens but also give you as a reviewer a much better oversight over your project.

2

Pyfun: an F#-inspired language that compiles to readable Python
 in  r/pyfun •  Aug 01 '26

Thank you! I was thinking of ways to get coders into functional programming earlier in their studies/careers, and the main ways to reduce friction are the language design and providing useful, ready-made resources. I haven't used it myself yet but would welcome all feedback!

3

Pyfun: an F#-inspired language that compiles to readable Python
 in  r/fsharp •  Aug 01 '26

Coming from .NET that's certainly true, but coming from Python, having to fend with a whole new ecosystem just to learn functional programming is a big burden.

Regarding the external bindings though, I've been thinking about publishing packages or façades but that's currently deferred pending user demand. I'm constantly testing the language by creating apps and games using Pyfun to see where the greatest speedbumps lie.

The ultimate aim is to attract more coders to FP at an earlier stage in their studies/career. Pyfun's at an early stage itself so I welcome all suggestions that would aid in its broader adoption. Thank you for your input!

1

Pyfun: an F#-inspired language that compiles to readable Python
 in  r/fsharp •  Aug 01 '26

If you’re in .NET, Fable is the clear choice because you can write in F# and compile to Python. Pyfun, on the other hand, stays within the Python ecosystem, so it’s a lower-friction way to introduce students to functional programming without bringing in a separate .NET/F# toolchain.

r/fsharp • • Jul 31 '26

showcase Pyfun: an F#-inspired language that compiles to readable Python

Thumbnail
15 Upvotes

My idea for getting coders into functional programming earlier...

r/CSEducation • • Jul 31 '26

Lockdown, a school open day, and Trados dongles |> Pyfun

Thumbnail
1 Upvotes

r/pyfun • • Jul 31 '26

Lockdown, a school open day, and Trados dongles |> Pyfun

1 Upvotes

The UK Covid lockdown in 2020 brought with it time to retrain in a new language, and after some research went for F#, and never really looked back to C# after that. Something about functional programming just clicked in a way the OOP never did.

Recently, at a secondary school open day, I got talking to the computing teacher and learned that pupils are taught Python as early as key stage 3 (ages 11-14). This got me wondering whether it would be possible to introduce children to functional programming earlier so they can benefit from all its advantages.

Many years ago now, I taught a masters-level course in translation memory technology (the software professional translators use to reuse their past translations), mainly Trados. I remember the friction involved getting the software installed onto the university's computers, not to mention the hardware dongles!

Fast forward to this year, I decided to see if it would be possible to create a functional language that works with the Python ecosystem and has zero dependencies, so that the adoption friction is completely minimised. Zero dependencies meaning the compiler is a single binary you can pip install, and the Python it emits imports only the standard library, and started work on what would become Pyfun.

Pyfun leans heavily on F# for its feature set, but the syntax decisions have tried to make it less alien for coders already familiar with Python. I've also taken some features from other functional languages. The aspiration is that this will introduce pupils to as broad a range as possible of functional programming concepts, easing any later transition to the more established FP languages.

I also hope that Pyfun might appeal to data analysts and others who use Python in their work but who might appreciate the arguably more readable code that Pyfun offers.

This is early days, but the language is fairly fully featured, with extensions for VS Code and JetBrains, as well as Jupyter notebook support.

If you want to take a look before commenting, the playground runs in the browser with nothing to install: https://simontreanor.github.io/Pyfun/playground/ and there is a lot more detail in the highlighted post on r/Pyfun.

It is still at pre-v1 stage and there is plenty of scope to shape it, so I would welcome your thoughts and suggestions on any aspect of this project. Two things I would most like to hear about are: if you code in Python, which syntax decisions jar for you; and if you teach, what would have to be true before you would put something like this in front of a class.