logoalt Hacker News

Type-checked non-empty strings

37 pointsby surprisetalklast Friday at 3:30 PM13 commentsview on HN

Comments

muglugtoday at 2:12 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.

IshKebabtoday at 2:00 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!

show 3 replies
ivanjermakovtoday at 1:36 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.

show 4 replies
swordlucky666today at 2:03 PM

[dead]