222 karma · joined Oct 13, 2020 (6y ago) · 24 submissions
comment 2y ago · link · parent
type Brand<BaseType, Brand> = BaseType & { readonly __brand__: Brand };
type FooId = Brand<string, 'FooId'>;
function fooBar(asdf: FooId | 'foobar'): void { }
fooBar will only accept the literal string 'foobar' or a true FooId, but not any arbitrary string. FooId would then come from a function that validates strings as FooIds, or some other part of the app that is an authoritative source for them. Brands extend their BaseType so they can be used anywhere their BaseType is used, but not the inversecomment 3y ago · link · parent
comment 4y ago · link · parent
It may be worth noting that effectful, polysemy, and the other "new kids" of effects systems are not the only option: record-of-functions, mtl, and type-class effects aren't cutting edge, but they're a little more approachable from an OOP dependency injection pattern.
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
Essentially, it's only useful for pasture raised cows (soy and corn fed feedlot cows already produce a fraction of the methane) and there's no practical way to add algae to pasture raised cows' diets. They also speculate that cows' microbiomes will adapt to the algae.
comment 5y ago · link · parent
comment 5y ago · link · parent