-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improving definitions for monoid, comonad, applicative, and ADT #230
base: master
Are you sure you want to change the base?
Conversation
@hemanth ? |
It's called a product because the total possible values of the data structure is the product of the different values. | ||
|
||
```ts | ||
type Rank = 'A' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | 'J' | 'Q' | 'K' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any other alternatives? @jethrolarson 🤓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infinitely many, but why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured playing cards were something that a lot of people are familiar with whose instances are a product of two sets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant instead of using ts
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it's a concept that only exists in type space so some kind of type syntax is necessary to describe it. Hmm I don't know how this would be represented in the pseudo-type system this document uses.
In F# which is a hindley-milner system it'd be something like
type Rank = A | Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | J | Q | K
type Suit = Spades | Hearts | Clubs | Diamonds
type Card = Rank * Suit
Is that better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hindley-milner for consistence, sure! Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My reticence is then that these named types have no representation in value-space and thus may make no sense in JS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nods, but hindley-milner would be bit more consistent?
Addressing some of the feed back in #220
I looked at "Lift" and while I can see that our definition is more general than "lambda lifting" I kinda prefer that the idea be generalized to all values not just functions. That I think make it easier to teach the idea of computation contexts in the way that Scott W does with the elevated worlds metaphor