Closed davidchambers closed 6 years ago
Good job! Find throwing me a mention for this?
Find throwing me a mention for this?
Adding a link to Control.Compactable do you mean, @Fresheyeball? That sounds good to me.
Got it. I think that could be clarified
Sent from my phone
El 1 dic 2017, a las 6:51 p. m., Gabe Johnson notifications@github.com escribió:
@gabejohnson commented on this pull request.
In README.md:
+
Maybe a
is used in type signatures in this specification. A JavaScript value +x
is of typeMaybe a
if: +
x.isJust
isfalse
; or
x.isJust
istrue
andx.value
is of typea
.+
{isJust: false}
representsNothing
;{isJust: true, value: 42}
represents +Just 42
.+###
Nothing
+
Nothing
is defined as:+```js +// Nothing :: Maybe a +const Nothing = {isJust: false}; Any conforming library which implements compact would also have to have an implementation of Maybe. There is no requirement that it have Maybe.prototype.isJust, just that compact can tell the difference between Nothing and Just a.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
This is really great work @davidchambers 👍 I think adding an abstraction that supports filter is a very worthwhile and practically useful endeavor. I think the arguments for Compactable are pretty solid. So while #274 was already really nice this PR seems even better. Naturally, I think representing the two possible return values from compact
with an object is a good choice 😉 It is very natural and easy to work with in JavaScript.
I must admit I had never heard of Compactable before the discussion in #274. I'll definitely be looking into it in more detail. I think a good abstraction that encompases filter
has been much needed.
I've been thinking this over, and I think we should just use the sum type we have (Boolean
). Introducing types to the spec should probably be done in a separate PR. We can always revisit Compactable
if Maybe
is added to the spec.
So my vote's for #274.
We can always revisit
Compactable
ifMaybe
is added to the spec.
Indeed. :)
Closes #33
This is an alternative to #274, based around
compact
rather thanfilter
.compact
refers toMaybe a
, so this pull request defines what is meant by a value of typeMaybe a
. I opted for “object encoding” as suggested by @paldepind, as it seems more idiomatic in a JavaScript setting.