alt.hn

6/26/2026 at 3:30:02 PM

Type-checked non-empty strings

https://exploring-better-ways.bellroy.com/haskell-koan-type-checked-non-empty-strings.html

by surprisetalk

6/29/2026 at 2:12:48 PM

Very cool that the language allows specification of a type in this way.

I added a similar type — “non-empty-string” to a typechecker for PHP, and it’s been adopted widely in the PHP ecosystem. It turns out to be pretty handy, especially when there’s a full type system to support it.

by muglug

6/29/2026 at 2:00:59 PM

"Huh never heard of Bellroy... I wonder what they're using Haskell for..."

Turns out it's some kind of bags and accessories brand!

by IshKebab

6/29/2026 at 5:26:13 PM

I bought a leather wallet from them in 2016 (the Hide & Seek) and it is still holding up well despite a few loose stitches. It’s much slimmer than my older wallet.

by kccqzy

6/29/2026 at 3:01:12 PM

I've had a Bellroy bag, they're not the most fashionable but super high quality and well thought-out. Just like Haskell code—maybe that's why they like it.

by flexagoon

6/29/2026 at 4:47:38 PM

In the backpack community bellroy is often seen as “meh”. Eg. they frequently don’t live up to the guarantees they give and to the quality they promise. Also overpriced.

by umpalumpaaa

6/29/2026 at 2:07:06 PM

I pondered for a while, it IS the company I used to know

by qbane

6/29/2026 at 4:02:01 PM

I once saw a job ad for a company selling a horoscope app that required Haskell. An unusual conjunction for sure.

by ambicapter

6/29/2026 at 6:58:03 PM

> An unusual conjunction for sure.

I see what you did there

by _doctor_love

6/29/2026 at 4:44:11 PM

Astrology and Haskell are quite similar in that both are much much easier to do if you have a math degree.

by saithound

6/29/2026 at 6:16:37 PM

For what it's worth, one of my classmates pivoted into astrology, and we majored in Applied Mathematics.

by throw-the-towel

6/29/2026 at 5:02:24 PM

Ok, I'll bite. How does a math degree help with astrology?

by recursive

6/29/2026 at 5:17:05 PM

The starting point of casting a horoscope is calculating the apparent locations (this means "where you would have seen them had you looked up there and then") of a whole bunch of celestial objects at the time and place where a particular person was born.

You won't (write software to) do that without knowing a whole bunch of linear algebra and ODEs.

The fortune-telling part is not what needs the math degree.

by saithound

6/29/2026 at 6:28:57 PM

Does the quality of the astrology depend on the correctness of celestial object positioning? I always assumed it had more to do with the "bedside manner" of the practitioner, and less to do with any measurable falsifiable phenomenon.

by recursive

6/29/2026 at 6:53:12 PM

You can't do good astrology if the underlying math calculations are wrong. Most mainstream Western astrology uses Placidus houses and then places planets in signs within those houses. From the planetary placements aspects (angles) are calculated.

The sign that a planet is in, which house, and aspects between the planets are what enables astrological fortune-telling and prediction (the forecasting aspect of astrology is technically known as transits and progressions, this is the "predicting the future" piece).

The bedside manner of the astrologer obviously has an enormous influence. One astrologer will look at a chart and treat it as a fixed "you are this way because of your chart" as if you can't change. A more thoughtful (read: actually good) astrologer will treat the chart as an evolutionary blueprint for growth and change. In many ways astrology is really just a different version of psychology and counseling.

A great book to read if you're open-minded but also don't want a bunch of "woo" is to check The Inner Sky by Steven Forrest. The first chapter of the book is called "Why Bother?" For what it's worth I had my chart read by Steven and it has really helped me in my life.

by _doctor_love

6/29/2026 at 5:18:23 PM

Are you sure? I can see for Astronomy that's a branch of physics so sure, there's loads of tricky practical mathematics so if you're bad at mathematics you'll get stuff wrong, but surely for Astrology since it's just bullshit anyway you don't need to do mathematics as it wouldn't make a difference?

by tialaramex

6/29/2026 at 6:56:00 PM

> since it's just bullshit anyway

Alright, you're on - post the place you were born, including date and time and I'll cast your chart and tell you what I see. Then you can tell me if you think it's bullshit or not.

Free reading, you have nothing to lose.

Example: Milpitas, CA @ 4:52am January 24 1987

by _doctor_love

6/29/2026 at 5:30:11 PM

A horoscope is a fine mixture of fortune-telling bullshit and verifiable astronomical facts. The latter have the form of "where the celestial bodies could be seen at the hour of the client's birth", or "does Jupiter currently appear to be moving forward or backward in the sky".

The average Visual Basic programmer and the world's best mathematician are going to be about equally good at writing the fortune-telling part, but the mathematician will have a much easier time getting the factual part right.

by saithound

6/29/2026 at 6:56:59 PM

I don't think the kinds of people that believe astrology are actually verifying the astronomy though.

by IshKebab

6/29/2026 at 4:30:20 PM

Using Haskell for a horoscope app is like hiring a mathematician to read tea leaves

by gib444

6/29/2026 at 4:57:55 PM

Astrology is a mixture of factual verifiable information (such as apparent positions of celestial bodies at the time and location a certain person was born) and random baseless divinations.

The "whale" users who account for a disproportionately large percentage of an astrologer's revenue tend to know the factual information surrounding their birth fairly well. An app/astrologer who doesn't get these facts right, even for a handful of clients, will get a bad reputation fairly quickly.

I reckon the same principle would hold in cultural bubbles where reading tea leaves is a customary means of divination. If the client recognizes recognize black tea, but the fortuneteller insists it is rooibos, there won't be much trust in the rest of the prophecy.

Advertising that the horoscope shop uses Haskell is actually a solid business idea. It pre-filters for the sort of dev who will be able to do the math.

by saithound

6/29/2026 at 5:40:45 PM

OK, I replied elsewhere without realising where you were going with this.

My impression (not interested in pseudo sciences so I haven't looked into this hard) was that Astrology froze before Kepler explains how the planets move, and so the model used by astrologers is just wrong and won't actually tell you what was in the sky when you were born for example?

You don't need Newton (who figured out why they do that) but you do need Kepler or your physical data will be wrong surely? It won't matter because this isn't actually a way to divine the future, but it will be wrong AIUI

by tialaramex

6/29/2026 at 5:55:55 PM

Astrology didn't really freeze. The apparent position of celestial objects was important for mundane reasons such as navigation until the 1970s, and the people who compiled nautical almanacs kept doing astrological fortune telling on the side for extra cash, using the very same math for both. Kepler himself cast horoscopes as a side hustle, including for the Holy Roman Emperor, using the same (back then cutting edge) techniques and data that he used for serious work.

Modern ascendant calculations are "correct", in the sense that they'll match what you see in the sky. Apps like AstroMatrix work from NASA data.

As you rightly observed, it doesn't make a difference when it comes to foretelling the future. But it does make a difference if your aim is to make money selling it. The big spenders on these applications often care a great deal about getting the particulars just so.

by saithound

6/29/2026 at 6:09:51 PM

Thanks, makes sense.

by tialaramex

6/29/2026 at 1:36:50 PM

Language is not mentioned in a title, so my first thought was about TypeScript type wizardry. Turns out it's as simple as `Exclude<string, "">`.

https://www.typescriptlang.org/docs/handbook/utility-types.h...

Edit: nevermind, LLM fooled me.

by ivanjermakov

6/29/2026 at 1:41:29 PM

It's simple, and it doesn't work as `Exclude` only applies to union types. For type `string` it just returns the same type `string`.

by antipurist

6/29/2026 at 1:39:53 PM

It is very much mentioned in the article title and the first sentence. It's just HN that's truncated the title.

by ralferoo

6/29/2026 at 2:35:01 PM

Daily reminder that TypeScript's type checker is not sound.

https://www.typescriptlang.org/play/?#code/C4TwDgpgBAcg9gOwK...

by nvme0n1p1

6/29/2026 at 5:10:36 PM

Daily reminder that the unsoundness in Typescript's type checker is a practical compromise applied to a language that was never designed to be type checked in this way, and furthermore that many developers feel that it strikes a good balance between formal correctness and practical usability.

by recursive

6/29/2026 at 4:25:52 PM

This example is not only wrong for what you intend to demonstrate but even if it wasn't, it's not problematic. In typescript the proper way to do this is using branded types and exporting only the safe constructor, making anyone who wants to violate the invariant go out of their way, which is no different from the situation in any number of programming languages or scenarios.

  declare const brand: unique symbol;
  type NonEmptyString = string & { readonly [brand]: 'NonEmptyString' };

  // the ONLY non-cast way to produce one
  export function nonEmptyString(s: string): NonEmptyString | undefined {
    return s.length > 0 ? (s as NonEmptyString) : undefined;
  }

  export type { NonEmptyString };

by IceDane

6/29/2026 at 2:03:26 PM

[dead]

by swordlucky666