Open davidchambers opened 5 years ago
I believe this to be an alternative to (if not an extension of) #286 which solves the problem described in https://github.com/rpominov/fantasy-land/issues/3 with the proposed type representative constructors.
Perhaps it could be worked into his fork of Fantasy Land, closing https://github.com/rpominov/fantasy-land/issues/3 and unblocking progress towards #286. Although this fork also introduces TypeScript types, which I think not everyone (including myself) would agree with.
The only idea that I think is worth sharing, is the idea of using a Symbol
instead of a String ('fantasy-land'
) to associate values with their type representative. A Symbol would have the following benefits:
typeRep
: https://github.com/fantasyland/fantasy-land/blob/6a4c689e07b5837f3608382d32480416eb1bdc98/proposal.js#L123-L138 [Symbols] would enable us to associate Type Representatives directly with String, Number, etc, without the need for a function like the proposed
typeRep
That would work for nullary types, but we would still provide typeRep
because the type representative of [1, 2, 3]
should be Array (Number)
rather than Array (Unknown)
.
I'm going to move ahead with this proposal. Expect a substantial pull request in the coming weeks. :)
This is an issue in spirit rather than a pull request. I am submitting the proposal in pull request form to facilitate threaded discussions and to allow changes to be made and tracked via Git.
The proposal is, I believe, sufficiently detailed, so I won't repeat myself here.
I asked @Avaq to review the proposal earlier today. He noted that this approach solves rpominov/fantasy-land#3. Aldwin has many ideas on this topic, which I hope he will share here. :)
/cc @alexandru, @robotlolita, @rpominov