Twitter | Search | |
Brandon Williams
Functional Believer. Previously . Available for hire: . Working on :
5,485
Tweets
384
Following
2,928
Followers
Tweets
Brandon Williams 2h
Replying to @echatav @py
Ha this should be easy for you! It’s even simpler than the coproduct of groups!
Reply Retweet Like
Brandon Williams Oct 16
Replying to @slava_pestov
Would you like me to file a bug ticket? Or is there anything I can do?
Reply Retweet Like
Brandon Williams retweeted
Elliot Schrock Oct 16
Excellent talk by about Playgrounds helped me fix a table-flip-level problem I was having. Give it a watch!
Reply Retweet Like
Brandon Williams Oct 16
Replying to @GFontenot
Hey! Congrats! Staying in TX?
Reply Retweet Like
Brandon Williams Oct 16
Replying to @py
Every monoid arises in such a way, but is probably awkward to use in practice.
Reply Retweet Like
Brandon Williams Oct 16
Replying to @py
There maaay be a way to do this if you force your monoid to be expressible as `Maybe s` for some semigroup `s`
Reply Retweet Like
Brandon Williams Oct 16
Replying to @py
however the coproduct of semigroups is totally expressible without such caveats.
Reply Retweet Like
Brandon Williams Oct 16
Replying to @py
Lol you cheated! Yeah that’s it, but it still isn’t a valid type-level description, precisely because of this comment:
Reply Retweet Like
Brandon Williams Oct 16
Replying to @py
The identity adds additional ambiguity that can not be resolved with just types. Need a runtime normalization
Reply Retweet Like
Brandon Williams Oct 16
Replying to @py
But not just sums and products
Reply Retweet Like
Brandon Williams Oct 16
Replying to @py
Do it in Haskell! It may be possible with dependent types
Reply Retweet Like
Brandon Williams Oct 16
Replying to @stephencelis
Well you can make a category of partial semigroups. Would have to think more about what their sums and products look like
Reply Retweet Like
Brandon Williams Oct 16
Replying to @stephencelis
No!
Reply Retweet Like
Brandon Williams Oct 16
Replying to @py
But essentially it has too many values and no way to exclude them at the type level
Reply Retweet Like
Brandon Williams Oct 16
Replying to @py
You gotta work out what the coproduct would look like to see!
Reply Retweet Like
Brandon Williams Oct 16
Replying to @loganmeetsworld
v cool! I might be wrong, but is there a typo in the `OR` definition? Should you be checking `== ‘0’`?
Reply Retweet Like
Brandon Williams Oct 16
Replying to @mbrandonw
8/ However it is *not* possible to do the same with monoids! We can not have a type-level description of coproducts of monoids in Swift
Reply Retweet Like
Brandon Williams Oct 16
Replying to @mbrandonw
7/ Can you construct this `C<A, B>`? It’s totally possible to have a type-level description of it in any language with sum types
Reply Retweet Like
Brandon Williams Oct 16
Replying to @mbrandonw
6/ It is called the coproduct in the category of semigroups. It is a type `C<A, B>` such that `A` and `B` naturally embed inside as semigrps
Reply Retweet Like
Brandon Williams Oct 16
Replying to @mbrandonw
5/ But, it’s possible to make a new type that kinda looks like the sum/union/enum of two semigroups
Reply Retweet Like